Java 邮递员404春季休息api
这是我的应用程序配置Java 邮递员404春季休息api,java,spring-boot,Java,Spring Boot,这是我的应用程序配置 spring.data.mongodb.host=192.168.56.1 spring.data.mongodb.port=27017 spring.data.mongodb.database=test server.port=8080 spring.application.name=test server.servlet.context-path=/test 这是我的控制器代码: package com.example.crud; import org.sprin
spring.data.mongodb.host=192.168.56.1
spring.data.mongodb.port=27017
spring.data.mongodb.database=test
server.port=8080
spring.application.name=test
server.servlet.context-path=/test
这是我的控制器代码:
package com.example.crud;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@RestController
@RequestMapping("/crud")
public class CrudOperation {
@GetMapping("/getAll")
public String getMethod() {
return "Get Datas success";
}
@PostMapping("/save")
public String saveMethod() {
return "save successfully";
}
@PutMapping("/update")
public String update() {
return "Update Data success";
}
@DeleteMapping("/remove")
public String delete() {
return "Delete Data success";
}
}
我无法访问Postman中的任何方法,我经常
404错误或找不到方法错误。
我尝试只使用简单的返回运行应用程序,但仍然
我面临着这个问题。
我做错了什么?
如果我的问题不够解释,请在评论中告诉我,不要标记为重复。更改您的答案
server.servlet.context-path=/test
到
post
url
您在运行后获得的以及您用于访问此应用程序的url这是我在postman localhost中使用的url:8080/test/crud/saveserver.servlet。上下文路径=/test/*
尝试此/test/*在部署tomcat@v8 EPlease时显示错误。请包含更多信息,如您正在使用的spring Boot版本使用。上面的答案是假设您使用的是SpringBoot2.0
server.servlet.contextPath=/test