簡體   English   中英

使用Rest API 404的Spring Boot

[英]Spring Boot with Rest API 404

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

application.properties

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

嘗試在@GetMapping內部提供映射URL,以將您的方法映射為:

@GetMapping("/mappingURL")

GET URL:本地主機:8080 / operationsOnEmployee / mappingURL

如果沒有清理項目,然后重新運行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM