I have created demo Spring Boot project and implemented Restful services as shown here
@RestController
public class GreetingsController {
@RequestMappin
If you are using @SpringBootApplication
alone, then make sure your rest service controller is in the same package like below -
com.testSpring->SpringBootApplication class com.testSpring.controller->RestfulController classes com.testSpring.model->Model classes ..etc
If you are using @ComponentScan(basePackageClasses = UserController.class)
, then mention specific controller class names.
For me I have the same error, but I realise that the path I put to call the api is the problem.
If my application name is demo, I have to call
http://localhost:9090/AdminProducts
to access AdminProducts,
not http://localhost:9090/demo/AdminProducts
. This name may be use after deploying the war in tomcat.
This can help someone as it was in my case.
Make sure the package name of the controller is the derived (or child) package of your Spring main method package.
For example:
If the main method package is com.company.demo.example then the controller package should be like com.company.demo.example.controller (if you specify something like com.company.demo.controller it won't work!).
all your packages should be after the main package,
like this com.example.demo.* (all your packages)