spring - org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helper' . No unique bean of type [java.lang.String] -
i want autowire string constructor.
i have in spring config xml:
<bean id="helper" class="test.helper">     <constructor-arg index="3" type="java.lang.string" value="http://test.com" />   </bean>   helper.java
@component public class helper {     private final clientfactory clientfactory;     private final modelmanager modelmanager;     private final securityservice securityservice;     private final string url;      @autowired     public helper(clientfactory clientfactory, modelmanager modelmanager,         securityservice securityservice, string url) {         this.clientfactory = clientfactory;         this.modelmanager = modelmanager;         this.securityservice = securityservice;         this.url = url;     } }   i getting error:
org.springframework.beans.factory.nosuchbeandefinitionexception: no unique bean of type [java.lang.string] defined: expected single matching bean found 19:
any appreciated. thanks!
try droping @autowired annotation in ctor , configuring in xml:
<bean id="helper" class="test.helper">     <constructor-arg ref="clientfactory" />       <constructor-arg ref="modelmanager" />       <constructor-arg type="java.lang.string" value="http://test.com" />       <constructor-arg ref="securityservice" />   </bean>      
Comments
Post a Comment