I made a library project using Spring Boot that should be reused by other projects. In this library project I have an interface that needs to be implemented by the project that uses the library, something like:
public interface MyService {
void doSomething();
}
I then autowire this interface in other beans in the library project like this:
@Service
public class AnotherLibraryService {
@Autowired
private MyService myService;
}
Obviously IntelliJ already tells me there is a problem: There is no bean for MyService
. I want the project that uses the library to provide a bean for this interface like this:
@Service
public class MyServiceImplInOtherProject implements MyService {
@Override
public void doSomething() {
}
}
The library project is included in the concrete project as a Maven dependency. I want the library project to use the bean provided by the concrete project when I autowire MyService
. Does anyone know how to configure this? Or is it not possible?
Btw: If I ignore the warning by IntelliJ and simply do it the way I described, the autowired MyService
is null in the library project, even when there is a bean that implements it in the concrete project.