spring - 带有 Rest API 404 的 Spring Boot
问题描述
API 在没有 spring-boot 的情况下工作,但在 spring-boot 下,它不是。
@RequestMapping("/operationsOnEmployee")
@RestController
public class OperationsOnEmployee {
@Autowired
EmployeeFacade employeeFacade;
@GetMapping(produces = "application/json")
public List<Employee> getEmployee() {
System.out.println("hello");
return employeeFacade.getAllEmployee();
}
应用程序属性
server.port:8080
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect
spring.datasource.url=jdbc:mysql://localhost:3306/company
spring.datasource.username=root
spring.datasource.password=root
"timestamp": "2019-08-01T11:34:07.631+0000", "status": 404, "error": "Not Found", "message": "No message available", "path": "/operationsOnEmployee"
解决方案
利用
@GetMapping(value= "/operation", produces = "application/json")
称呼
GET: localhost:8080/operationsOnEmployee/operation
另外,请确保您没有在application.properties中定义任何路径
server.servlet.context-path= #some path
推荐阅读
- reporting-services - SSRS Report tablix - 在页面上换行 2 列,并带有组分页符
- c++ - 如何在 Visual Studio 程序中包含 GCC 标头;有没有额外的“陷阱”步骤?
- reactjs - React 传单如何让所有标记都带有特定图标,但使用不同图标激活的标记
- c++ - C ++ 17使用reduce与乘法相乘的列表不起作用
- html - Mac 上的填充看起来与 Windows 上的不同
- python - 如何让我的 Python 脚本无限运行(循环)?
- android - How do I parse this Dynamic JSON value with Retrofit 2 and GSON?
- r - 计算利用率分布的交集量
- lazy-loading - 延迟加载比急切加载更好吗?
- visual-studio - 每次我构建一个虚幻引擎项目时,vs都会发出这样的警告:无法获取MBCS字符串