I have made several applications which use a pure annotation Spring configuration. Now, I would like to try to build a library.
- The library should use pure annotation Spring configuration.
- Projects which use the library should be able to use the library without any special Spring configuration. Indeed, I want the library to be usable interchangeably with Spring and non-Spring projects. All Spring configurations should be handled within the library jar.
- The library should be usable in projects that are not web applications.
- Applications using the library should be able to instantiate public classes in the library with the
new
keyword, and for their@Autowired
dependencies to be resolved.
I am not sure how one would go about doing this. There would need to be some way of establishing the application context, and this seems to be done at the insertion point. Since libraries have no insertion point, I am at a loss.
Is this just something that is not done? Spring dependency injection seems to be a very useful tool and it would be a shame if I couldn't use it to build libraries.