Reputation: 73
We generally define our main application class in a root package above other classes.
The Spring Boot Application annotation in the main application class implicitly loads other classes as its the base package.
MY Question my main class is in com.example.main my controller class package is com.example.controller
when i run as Spring boot app, application is loaded but the rest API throws 404, how to configure parallel
Upvotes: 0
Views: 1118
Reputation: 1001
As your main class is not in root package, you need to annotate @componentScan
in your main class as below.
@SpringBootApplication
@ComponentScan({"com.example.controller"})
public class SpringBootApplication {
//...your code.
}
In case you want to scan all the sub-class you need to pass the root package path in componentScan
@ComponentScan({"com.example"})
Upvotes: 1