spring - No mapping found for HTTP request with URI [/CalorieTracker/] in DispatcherServlet with name 'dispatcher' -


this application configuration class:

@configuration @enablewebmvc @componentscan(basepackages = "com.spring") public class appconfig extends webmvcconfigureradapter{      @override     public void addresourcehandlers(resourcehandlerregistry registry) {         registry.addresourcehandler("/resources/**").addresourcelocations("/resources/");     }  } 

this application configuration initializer class. public class appconfiginitializer extends abstractannotationconfigdispatcherservletinitializer{

@override protected class<?>[] getrootconfigclasses() {     // todo auto-generated method stub     return new class[] {appconfig.class}; }  @override protected class<?>[] getservletconfigclasses() {     // todo auto-generated method stub     return null; }  @override protected string[] getservletmappings() {     // todo auto-generated method stub     return new string[] {"/"}; } 

}

this rest controller class.

@restcontroller @requestmapping("/user") public class usercontroller {      private userservice userservice;  @requestmapping(method = requestmethod.post)     public responseentity<userresource> createuser(@requestbody userresource userdetails) {         try {             user createduser = userservice.createuser(userdetails.touser());             userresource res = new userresourceasm().toresource(createduser);             httpheaders headers = new httpheaders();             headers.setlocation(uri.create(res.getlink("self").gethref()));             return new responseentity<userresource>(res, headers,  httpstatus.created);         } catch (userexistsexception e) {             throw new conflictexception(e);         }     } } 

in console getting warning

warn : org.springframework.web.servlet.pagenotfound - no mapping found http request uri [/calorietracker/] in dispatcherservlet name 'dispatcher' 

i believe because of warning when tried call rest api "http://localhost:8080/calorietracker/user", getting status 404.

can wrong while configuring program?

change

@requestmapping("/user") public class usercontroller 

to

@requestmapping("/") public class usercontroller 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -