shantanu
shantanu

Reputation: 2418

URI not found 404 spring boot

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.

Error

{
    "timestamp": 1519069359705,
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/profile/5"
}

Controller

@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);
    }
}

Server Log

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

Answers (1)

Pablo
Pablo

Reputation: 307

You should use 'value' instead of 'name' in RequestMapping:

@RequestMapping(value = "/{id}", method = RequestMethod.GET)

Upvotes: 3

Related Questions