URI找不到404弹簧启动

时间:2018-02-19 19:54:17

标签: java spring-boot intellij-idea

我正在使用intellijspring-boot来构建服务器应用程序。但它经常显示404 URI not found error。特别是当我在课堂上宣布@RequestMapping时。

错误

{
    "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 ....

注意ProfileController的包有多个图层。与com.company.project.modules.profiles.controller com.company.project包中包含Application一样。我试过@ComponentScan但没有帮助。同时使IDE cache无效。

1 个答案:

答案 0 :(得分:3)

你应该使用' value'而不是' name'在RequestMapping中:

Set propSet = properties.entrySet()

propSet.each {
    def key = it.getKey()
    def value = it.getValue()

    env."${key}" = value
}