title: Spring Annotation Configuration in a library
body: <p>I have made several applications which use a pure annotation Spring configuration. Now, I would like to try to build a library. </p>
  
  <ul>
  <li>The library should use pure annotation Spring configuration.</li>
  <li>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. </li>
  <li>The library should be usable in projects that are not web applications.</li>
  <li>Applications using the library should be able to instantiate public classes in the library with the <code>new</code> keyword, and for their <code>@Autowired</code> dependencies to be resolved.</li>
  </ul>
  
  <p>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.</p>
  
  <p>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. </p>