Hi,
I’ve noticed that after upgrading to spring 4.0.0 autowiring repositories is no longer possible.
It will throw an exception indicating that it is not possible to autowire Repository because there are no such bean.
If you leave out the generics it will work.
I use the axon 2.0.7
Sample code
@Component
public class BatchCommandHandler {
private Repository repository; @CommandHandler
public void handleCreateBatch(CreateBatchCommand command) {
Batch batch = new Batch(command.getBatchId);
repository.add(batch);
} @Autowired @Qualifier(“batchRepository”)
public void setRepository(Repository batchRepository) {
this.repository = batchRepository;
}
}
they have changed the way Spring works with generics in 4.0.0. They now see generics as some form of qualifier.
When providing an explicit @Qualifier, does the proper repository get injected, or does it also fail in that case?
Have you tried autowiring by name instead of by type -- using one of the other dependency injection annotations? I think we had to use @Resource("myRepositoryName"). @Autowired+@Qualifier is still auto wiring by type + a filter. So is @Inject+@Named.