Reputation: 4373
For instance, in the xml file, I have defined some String values:
<bean id="name" class="java.lang.String" >
<constructor-arg type="java.lang.String" value="SMITH" />
</bean>
While in the component class, how can I inject this into its class member?
@Component
public class Person {
private String name; // @Autowired doesn't work here
}
How can I inject the String 'name' defined in the xml file into Person? @Autowired doesn't work. Is there any workaround here?
Upvotes: 0
Views: 324
Reputation: 57381
Try to annotate with @Resource
@Resource(name="name")
private String name;
Upvotes: 1