我想将字符串自动连接到构造函数。
我在spring config xml中有这个:
<bean id="helper" class="test.Helper">
<constructor-arg index="3" type="java.lang.String" value="http://test.com" />
</bean>
助手.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;
}
}
我收到错误:
org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义类型 [java.lang.String] 的唯一 bean:预期单个匹配 bean,但找到 19:
任何帮助表示赞赏。谢谢!