我的Spring配置xml文件中有以下aspectJ定义
<bean id="valueLogging" class="org.beans.ValueLogging">
<constructor-arg value="#{T(System).out}" />
</bean>
<aop:config>
<aop:aspect ref="valueLogging">
<aop:pointcut id="settingValue" expression="execution(* *.setValue(..)) and args(parameter, value)"/>
<aop:after pointcut-ref="settingValue" method="logAfterSettingAValue" />
</aop:aspect>
</aop:config>
然后,我有ValueLogging
类:
public class ValueLogging {
private PrintStream stream;
public ValueLogging(PrintStream stream) {
this.stream = stream;
}
public void logAfterSettingAValue(final Object element, final String parameter, final Double value) {
stream.println(element + " :The value " + value + " has been set to the parameter " + parameter.getName());
}
}
我收到初始化错误。以下是跟踪的一部分:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'networkElement' defined in class path resource [META-INF/spring/parameterChange.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: this [Xlint:invalidAbsoluteTypeName]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.ericsson.domain.ParameterChangeMain.main(ParameterChangeMain.java:16)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with nam
我认为这是因为我无法捕获方法的调用者以将其作为logAfterSettingAValue
方法的参数。
有什么想法吗?