I have an application that was working in Spring Boot 1.5, than worked in 2.0. Now I'm migrating to 2.5.7
This application uses a external lib. This lib also written using Spring Boot 2.5.7 and it users OpenFeign.
But now, when running, the main application seens not to be scanning the lib.
The error is:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field usersRestClient in my.library.package.infrastructure.acl.facade.user.UserFacade required a bean of type 'my.library.package.infrastructure.acl.restclient.user.UsersRestClient' that could not be found.
The injection point has the following annotations:
- @javax.inject.Inject()
Action:
Consider defining a bean of type 'my.library.package.acl.restclient.user.UsersRestClient' in your configuration.
I already tried to use ComponentScan at diferent places. I tried to Create a Configuration Class with ComponentScan at the lib and point in the main application using @Import. Nothing worked.
I've edited the code leaving just whats matters.
In the lib: The Service UserFacade uses the Component UsersRestClient
@Service
// I've already tried to put @ComponentScan here, didn't work.
public class UserFacade {
@Autowired
private UsersRestClient usersRestClient;
...
}
This is the component:
@RequestMapping("/users")
@Component("usersRestClient")
public interface UsersRestClient {
...
}
In the main App:
The main class
@SpringBootApplication
@ComponentScan(basePackages = {"my.library.package"})
@EnableAutoConfiguration
@EnableFeignClients({"my.library.package"})
public class ResourceAllocationServiceApplication {
...
}
Than, where I use the UseFacade Service:
@Component
public class RetrieveUserByIdUseCase {
@Autowired
private UserFacade userFacade;
...
}
Can anyone help? I found a similar issue here, but no answers worked. @ComponentScan on external library not working