I am facing an issue with dependency injection in my Spring Boot Application. While testing Project C, I am encountering a bean not found error for com.project.ProjectA.repository
. I have included the necessary packages in @SpringBootApplication(scanBacsePackages)
, but the bean is still not found. Any insight on resolving this issue?
Parameter 0 of constructor in com.project.ProjectC.AILogController
required a bean of type com.project.ProjectA.service.TestingLogService
that could not be found.
Consider defining a bean of type ‘projectA.TestingLogService' in your configuration.
@SpringBootApplication(scanBasePackages = {"com.project.projectA”, "com.project.ProjectB”, "com.project.ProjectC”})
public class ProjectCApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectCApplication, args);
}
}
pom.xml
<dependency>
<groupId>com.project</groupId>
<artifactId>projectA</artifactId>
<version>0.0.1</version>
<scope>system</scope>
<systemPath>${projectA-systemPath}</systemPath>
</dependency>
<dependency>
<groupId>com.project</groupId>
<artifactId>projectB</artifactId>
<version>0.0.1</version>
<scope>system</scope>
<systemPath>${projectB-systemPath}</systemPath>
</dependency>
I'm expecting to merge three spring boot projects together.
I've created jar files for com.project.ProjectA
and com.project.ProjectB
and added it to com.project.ProjectC
.
I am able to build the project with out any errors by running the command mvn clean install
. However, I'm facing errors when I attempt to run the command mvn spring-boot:run
.
To troubleshot this, better to have the stack trace of the exception. But there are couple of things you can check:
com.project.ProjectA.service.TestingLogService
is annotated with @Component
or @Service
?com.project.ProjectA.service.TestingLogService
is on the classpath?Based on your code the first is more probable to be the culprit.