make sure your main application class (StudentSystemApplication.java) has component scanning enabled for the correct base package. It should look like this:
@SpringBootApplication
@ComponentScan(basePackages = "com.connectingfrontandback")
public class StudentSystemApplication {
public static void main(String[] args) {
SpringApplication.run(StudentSystemApplication.class, args);
}
}
Because @SpringBootApplication
includes component scanning functionality that automatically detects annotations like @RestController, @Service
, @Repository
, and @Component
. When these annotations are found, Spring creates and manages those classes as beans. However, this scanning only works within the package containing your main class and its sub-packages.
So if your main application class is in a different package than your components, you need to explicitly add @ComponentScan(basePackages = "com.connectingfrontandback")
to ensure Spring finds and manages all your annotated classes correctly.