if I have the two classes below as we could see this is a constructor injection for SomeBean, however the constructor in SomeBean only has the constructor with parameter "String words", so during the dependency injection how do we specify the parameter for the constructor of the dependency?
@Component public class SomeBean { private String words; public SomeBean(String words) { this.words = words; } public String getWords() { return words; } public void setWords(String words) { this.words = words; } public void sayHello(){ System.out.println(this.words); } } @Service public class MapService { private SomeBean someBean; @Autowired public MapService(SomeBean someBean) { this.someBean = someBean; } public MapService() { } public void sayHello(){ this.someBean.sayHello(); } }
@Beanmethod to define yourSomeBeanobject.