1 year ago
#77395
Mem
UnsatisfiedDependencyException: Error creating bean with name 'myController'
I am calling a service class: "CustomUserService" from MyController.
public class MyController{
private final CustomUserService userService;
@Autowired
public MyController(
CustomUserService userService) {
this.userService = userService;
}
The userService is as follows:
@Service
public class CustomUserService implements ICustomUserService {
@Autowired public CustomUserService(SpringAuthClientCustom authClient){
this.authClient = authClient; } }
My authClient is:
@Service
public class SpringAuthClientCustom extends AbstractCustomSpringClient {
}
which extends: public abstract class AbstractCustomSpringClient {}
AbstractCustomSpringClient is from the external jar and I have added that to my dependency.
Now, I am getting
Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SpringAuthClientCustom' defined in file [C:\Users..\SpringAuthClientCustom.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.**..AbstractCustomSpringClient ] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@1d44bcfa]
I have added scanBasePackages in the BootAplication:
@SpringBootApplication(
scanBasePackages = { ""com.externalJar.client.*"}
Still, spring is not able to resolve the dependency. What could be the possible reason? Is it because of the AbstractCustomSpringClient class outside my project ( in the jar) and not defined as @Service?
Thanks
java
spring-boot
0 Answers
Your Answer