Eclipse 日食上带spring的aop

Eclipse 日食上带spring的aop,eclipse,spring,aop,Eclipse,Spring,Aop,我正试着用弹簧做一个小程序 <bean id="mybean" class="com.spr.main.Persona" p:name="Peter" p:age="33" p:address="LA" p:company="Googel" p:email="Peter@google.com" /> <bean id="logger" class="com.spr.main.Log" /> <

我正试着用弹簧做一个小程序

<bean
    id="mybean" 
    class="com.spr.main.Persona"
    p:name="Peter" 
    p:age="33" 
    p:address="LA" 
    p:company="Googel" 
    p:email="Peter@google.com"
/>

<bean id="logger" class="com.spr.main.Log" />

  <aop:config>
    <aop:aspect ref="logger">
        <aop:pointcut id="testPointcut"
                      expression="execution(* com.spr.main.Person.toString(..)) and target (bean)" />
        <aop:before method="logInfo" pointcut-ref="testPointcut" arg-names="bean"/>
        <aop:after-returning method="logWarning" pointcut-ref="testPointcut" arg-names="bean"/>
    </aop:aspect>
</aop:config>

您希望通过代码实现什么?AOP配置在我看来有点困惑。执行表达式针对日志类,aop通知方法也在日志类中定义。让一个类尝试拦截自己有点奇怪,不是吗?这只是为了学习一点spring的测试,抱歉执行(*com.spr.main.Log.toString(..)就是执行(*com.spr.main.Person.toString(..)
public class Log 
{

public static void logInfo()
{
    Logger.getLogger(Log.class.getName()).log(Level.INFO, "Info Message...");
}

public static void logWarning()
{
    Logger.getLogger(Log.class.getName()).log(Level.WARNING, "Warning Message...");
}
}