Just migrating from xml based config to java based config in Spring 4.3.
In xml we had
<beans ... default-autowire="byName">
<component-scan .../>
...
</beans>
On Java classes we have no @Autowired annotations on fields:
@Component
public class MyService {
private OtherService otherService;
// +setters
....
}
Previously in xml With the default-autowire="byName"
autowiring worked pretty well.
Now when moving to JavaConfig I cannot find a way to enable the default autowire mechanism for component scanning.
With autowire by name the wiring works without a @Autowired annotation.
With @Bean(autowire=BY_NAME) i can define a bean to autowire by name, but I would need that mechanism for component scanning. Not to define all beans with @Bean factory method.
Also I try not to add @Autowired annotations to all fields across all classes. Thats just too much to change.
My question now is: How to tell component-scan to autowire found beans by name?