[color=#FF0000]错误消息
exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'zhidingadive' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at test.test.main(test.java:17)
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 14 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
... 18 more[/color]配置文件
<bean id="zhidingadive"
class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="mappedNames">
<list>
<value>getPaperSize</value>
</list>
</property>
<property name="advice">
<ref bean="b5" />
</property>
</bean>大家看看有什么问题,晕。正确后马上结贴。
exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'zhidingadive' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at test.test.main(test.java:17)
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 14 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [Paper.B5] to required type [org.aopalliance.aop.Advice] for property 'advice': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
... 18 more[/color]配置文件
<bean id="zhidingadive"
class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="mappedNames">
<list>
<value>getPaperSize</value>
</list>
</property>
<property name="advice">
<ref bean="b5" />
</property>
</bean>大家看看有什么问题,晕。正确后马上结贴。
解决方案 »
- 单独的js文件如何获取系统根目录?
- 软件工程重要吗?
- JAVAMAIL问题:Access to default session denied
- 200分,哪位高人有用JFreeChart 画出柱状图后,手动控制其bar宽度的经验?
- 我原先是用while (it.hasNext)代码从类数组中读出数据的,现在想用JSTL这样的标签读出数据
- 问关于出租和求租两个单词怎么写
- 问一个JSP上传时出现的问题,郁闷了一天了,请求帮忙~~
- jsp初学都的一个问题.搞了一天搞不定.
- UrlRewriteFilter可以否实现二级域名的处理
- 我是新手,为什么程序里没有判断用户名和密码的语句呢
- spring 自动代理事务的问题
- 请问onmouseover=show("date") onmouseout=hide("date") 是什么意思
<ref bean="b5" />
</property> 通知配置有问题
<beans>
<bean id="colorInc" class="Inc.ColorInc"/>
<bean id="greyInc" class="Inc.GreyInc"/>
<bean id="a4" class="Paper.A4">
<property name="size" value="a4"/>
</bean>
<bean id="b5" class="Paper.B5">
<property name="size" value="b5"/>
</bean>
<bean id="printer1" class="Printer.Printer">
<property name="inc" ref="colorInc"/>
<property name="paper" ref="a4"/>
</bean>
<bean id="printer2" class="Printer.Printer">
<property name="inc" ref="greyInc"/>
<property name="paper" ref="b5"/>
</bean>
<bean id="logAdvice" class="Advice.logAdvice"/>
<bean id="AfterAdvice" class="Advice.AfterAdvice"/><!--
<bean id="zhidingadive"
class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="mappedNames">
<list>
<value>getPaperSize</value>
</list>
</property>
<property name="advice">
<ref bean="b5" />
</property>
</bean>
-->
<bean id="proxyBean" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>Paper.Paper</value>
</property>
<property name="interceptorNames">
<list><value>logAdvice</value></list>
</property>
<property name="target" ref="b5"/>
</bean>
<ref bean="b5" />
改成
<property name="b5">
<ref bean="b5" />
试试。
B5不能是一般的类,你的Paper.B必须5实现org.aopalliance.aop.Advice接口没?
参考前置通知:
public class B5implements MethodBeforeAdvice {public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
Date date = new Date();
System.out.println("信息:["+date.toLocaleString()+"] 调用了createPerson()方法。");
}
}