Core container refinements in Spring Framework 4.3

Spring Framework 4.3.RC1 is around the corner and brings nice core container refinements which we are going to explore in this post…

Implicit constructor injection for single-constructor scenarios

Consider the following service class:

@Service
public class FooService {

    private final FooRepository repository;

    @Autowired
    public FooService(FooRepository repository) {
        this.repository = repository
    }
}

Quite a common use case but if you forget the @Autowired annotation on the constructor, the container will throw an exception looking for a default constructor, unless you explicitly indicate autowire mode ‘constructor’ in your bean definition setup (e.g. in an XML <bean>).

Read more...