CRISTIAN LORENZETTO opened SPR-16835 and commented

I cant inject a string in a bean using xml. Actually i m using constructor(Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies ....). 

Some developers use @Value annotation but there is 2 problems.

1) if i use @Value i suppose to use my component forcely with spring. I can have a indipendent component indipendent by injection framework. Why forcely to write code in the source related to spring? 

2) @ Value writes in the code the label to use . But a class can have multiple instance , for each one to have a different value. so it is wrong conceptually if there is no other way  

3) if i create a second bean with name equals to the string value , the first bean is created correctly accepting that string. It is seams really another bug 

4) strangelly using index in constructor now works


No further details from SPR-16835

Comment From: snicoll

Without a sample that showcases what happens, this issue is no longer actionable. It looks like you're trying to inject something from the environment and expect a simple String declaration to do the same thing (whereas it would actually attempt to find a bean of type String in the bean factory.

I am going to close this as this looks like a user question to me that should have been asked on SO.