Spring 依赖注入(hint: specify index and/or type arguments for simple parameters to avoid type ambiguiti)

来源:互联网 发布:如何成为淘宝主播 编辑:程序博客网 时间:2024/06/01 07:48
<bean id="feeCodeSogouConfig"
class="com.sech.zengzhi.service.config.FeeCodeSogouConfig">
<constructor-arg>
<ref bean="userService" />

</constructor-arg>

<constructor-arg>
<ref bean="advertisingService" />
</constructor-arg>

<property name="searchDataService">
<ref local="searchDataService" />
</property>
<property name="sysConfig">
<ref local="sysConfig" />
</property>

</bean>


错误信息:16:37:18,109 ERROR ContextLoader:205 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feeCodeSogouConfig' 
defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 2 constructor arguments specified but no 
matching constructor found in bean 'feeCodeSogouConfig' 
(hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)


原因是

构造函数写错了..注入的时候找不到构造函数
public FeeCodeSogouConfig(UserService userService,AdvertisingService advertisingService) {logger.debug("initializes....");this.userService = userService;this.advertisingService=advertisingService;this.loadUserCodes();}
加上红色的问题解决