注入类
@Entity
public class operationData {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer ID;
private String username;
private String password;
private Integer age;
public operationData() {
}
public void setusername(String username) {
this.username=username;
}
public void setAge(Integer age) {
this.age=age;
}
public void setpassword(String password) {
this.password=password;
}
public String getusername() {
return username;
}
}
借口
public interface userInsterface extends JpaRepository<operationData,Integer>{
public List<operationData> findByAge(Integer age);
}
控制器
@RestController
public class useroperationhttp {
operationData od=new operationData();
@Autowired
private userInsterface us;
@PostMapping(value="/ca")
public operationData PostUser(@RequestParam("password") String pwd,@RequestParam("age") Integer age,@RequestParam("username") String usedata){
System.out.println("----name"+usedata);
od.setAge(age);
od.setpassword(pwd);
od.setusername(usedata);
return us.save(od);
}
启动项目第一次执行的是插入语句,不知为什么发送第二次数据就变为修改了
pardon110