我可以用Spring数据Rest进行PUT但不能POST吗?
我有两个这样的简单实体:我可以用Spring数据Rest进行PUT但不能POST吗?,spring,rest,spring-data,spring-data-rest,hateoas,Spring,Rest,Spring Data,Spring Data Rest,Hateoas,我有两个这样的简单实体: public class Agent extends BasedEntity { private String firstname; private String lastname; @ManyToOne @JoinColumn(name="agency_id", nullable=true) Agency agency; } 及 它通过了,但是如果我发一个帖子到 https://localhost:8080/api/v1
public class Agent extends BasedEntity {
private String firstname;
private String lastname;
@ManyToOne
@JoinColumn(name="agency_id", nullable=true)
Agency agency;
}
及
它通过了,但是如果我发一个帖子到
https://localhost:8080/api/v1/agents/64/agency
body:https://localhost:8080/api/v1/agencies/50
我得到一份工作
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
您使用的是旧版本的Spring数据Rest。允许从2.3.x开始POST 最新版本是3.2.x。你应该升级到一个更新的版本 ------编辑 我刚刚意识到,异常不是RepositoryPropertyReferenceController类中的内部HttpRequestMethodNotSupportedException,而是“default”org.springframework.web.HttpRequestMethodNotSupportedException 此异常从不直接从SRD包引发
可能您有一个过滤器,它拒绝POST请求或某种安全设置。Im在我的类路径中使用spring-data-rest-core-3.1.11.RELEASE.jar和spring-data-rest-webmvc-3.1.11.RELEASE.jar,所以这不是原因。还有其他想法吗?
https://localhost:8080/api/v1/agents/64/agency
body:https://localhost:8080/api/v1/agencies/50
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported