"status": 404, "error": "not found", "message": "no message available", "path": "/api/employee"
first, make sure the YourController.java file that has the @Controller and the YourSpringBootFile.java file that has the @SpringBootApplication are in the same package.
If you want your controller to be in a different package outside of YourSpringBootFile.java's package, then follow these instructions = Spring: Run multiple "SpringApplication.Run()" in application main method
There are 2 methods to overcome this
Place the bootup application at the start of the package structure and rest all controllers inside it.
Example :
package com.spring.boot.app; - You bootup application(i.e. Main Method -SpringApplication.run(App.class, args);)
You Rest Controller in with the same package structure Example: package com.spring.boot.app.rest;
Explicitly define the Controller in the Bootup package.
Method 1 is more cleaner.
referred to: https://stackoverflow.com/questions/31318107/spring-boot-cannot-access-rest-controller-on-localhost-404
Comments
Post a Comment