How is it possible to define a Spring beans which need only @Autowired for defining new bean of certain type?
I have seen a solution, where service layer services are created without extra bean definitions for the new service. With bean definition I mean a line on config file specific to this service.
Is it possible to define beans so that certain package for example com.foo.bar.service.* become automatically defined with only adding @Autowired when calling it and not defining any other config per class in that package?
You might be able to write your own code that scans a Java package, and adds a bean for each of the classes found. That’s not usually what is required, as many packages have helper classes that should not be exposed as beans.
But more likely, the beans will have one of the
@Component, @Repository, @Service, @Controllerannotations on them, and Spring will then register these as beans.http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-scanning-filters