实例工厂方法创建Bean时配置init-method配置文件报错,但程序能正常运行,找不到原因很是郁闷!下面是配置:<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="personServiceFactory" class="service.impl.PersonServiceBeanFactory"/>
<bean lazy-init="false" init-method="init" destroy-method="destory" id="personService" factory-bean="personServiceFactory" factory-method="createPersonServiceBean"/>

</beans>以下是报错:Multiple annotations found at this line:
- Destroy-method 'destory' not found in bean class 
 'service.PersonService'

解决方案 »

  1.   

    你的bean中没有找到destory方法
      

  2.   

    这个事bean销毁是首先调用的方法。没找到就跳过了
      

  3.   

    这个问题到是解决了,原因是Spring是面向接口的默认到接口寻找方法,我只是在实现类中定义了init()方法和destory()方法接口中没有定义,所以就报了Destroy-method 'destory' not found in bean class 
    'service.PersonService,看嘛它是到PersonService中找的是我大意了没注意。这个问题解决了,谢谢大家了。不过实例工厂方法创建Bean时配置又发现一个新毛病,在实现类中属性的get(),set()方法Spring也到接口中去早,这就郁闷了,一直没有找到解决方法,请各位支支招!再次谢谢了!