Reputation: 2418
I'm using intellij
and spring-boot
to build server application. But it's frequently showing 404 URI not found error
. Specially when I declare @RequestMapping
in class.
{
"timestamp": 1519069359705,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/profile/5"
}
@RequestMapping("/profile")
@RestController
public class ProfileController {
@Autowired
private ProfileService profileService;
@RequestMapping(name = "/{id}", method = RequestMethod.GET)
public Profile get(@PathVariable("id") int id){
return profileService.get(id);
}
}
Mapped "{[/profile],methods=[GET]}" onto public ....
Note: ProfileController
's package has several layers. Like com.company.project.modules.profiles.controller
where com.company.project
package contains Application
. I tried @ComponentScan
but didn't help. Also invalidate IDE cache
.
Upvotes: 0
Views: 1787
Reputation: 307
You should use 'value' instead of 'name' in RequestMapping:
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Upvotes: 3