In IntelliJ IDEA, I am getting the following error:
Could not autowire. No beans of 'ExternalClass' type found. Inspection info: Checks autowiring problems in a bean class
Background: I extracted a part of the code, and uploaded it as an artifact, when I tried to use it in my "main" code I got the error, and I'm unable to compile with maven.
@Autowired
public ClassName (ExternalClass externalClass){
this.externalClass = externalClass;
}
The artifact is a dependency in the POM file, and it shows up fine on autocomplete.
I have tried with several classes, and the error comes every time.
I found the issue eventually and is sharing in case someone else gets the same error. For autowire and spring to work properly, the artifact needed the same package structure as the main project. Example: if main project package structure is:
com.domainname.something.myproject
The artifact should be:
com.domainname.something.myproject.artifactname