Autowiring a Spring Bean from External JAR
I have created an external library for my Spring Boot projects, let’s call it korimlib. It contains a reusable service.
package com.korimsoft.korimlib;
@Autowired
public class MyReusableService {
}
I have imported the korimlib into the Korimapp - one of the korimlib's consumers.'
One would expect that a simple import in a client class would do. Well, Spring Boot is not that clever.
If I try tu run this simple example, I get an UnsatisfiedDependencyException. The DI container is not able to locate MyReusableService. There is one more thing to do: Configure the DI container to look also in the external library for dependencies.
Voila!