首先,明确一点405问题就是浏览器端(或客户端)请求方法和服务端处理该路径的请求的处理方法不一致造成的。
背景:SpringBoot2.70整合JPA,测试单表的增删改查
现象: 在用postman测试delete方法的时候遇到的
图1: postman测试截图
图2:后端代码块
package com.xxxx.salesforecast.Controller;
import com.xxxx.salesforecast.pojo.User;
import com.xxxx.salesforecast.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 用户外部接口
*
* @author : liuke
* @date : 2022-06-22 14:20
**/
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserRepository userRepository;
/**
* 插入
*
* @param user
* @return
*