[英]Getting 404 - No message found after migrating to Spring Boot 2.x
在完成从Spring Boot 1.5.4迁移到2.1.1的所有必要更改后,出现了404 not found错误。 我认为这与控制器的网址映射有关。 我已经将我的控制器包放在主类之后,确保我的主类和控制器放置在正确的位置。 我还使用了@ComponentScan和@SpringBootApplication批注。
@RestController
@RequestMapping("/feature")
public class FeatureController {
@RequestMapping(value = "user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getFeatureForuser(@PathVariable("user_id") String userEId) {
LOGGER.info("Fetching the avaliable features for User: {}", userEId);
// Invoke the service layer.
return service.getFeatureForuser(userEId);
}
}
在将application.properties文件中的server.contextPath更改为server.servlet.context-path之后,我能够修复此问题,因为从Spring Boot 2.x起,许多servlet特定属性已从server。*更改为server.servlet。*。
我希望这会有所帮助。 谢谢大家的帮助!
您是否尝试过@SpringBootApplication(scanBasePackages =“提供您的基本软件包”)
而且@RequestMapping(value =“ user”应该是@RequestMapping(value =“ / user”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.