SpringCloud 통합 JPA Feign 원격 호출 보고서 415 Unsupported Media Type

3822 단어 springCloudFeign
	   cloud  jpa feign     .        feign        ,      415
	
		ERROR 41780 --- [nio-6001-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException: status 415 reading ConsultFeign#updateStatus(Consult); content:
{"timestamp":1574683530783,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Content type 'application/json;charset=UTF-8' not supported","path":"/consult/updateStatus"}] with root cause

이상은 오류 정보입니다. 검사할 때 POST 전참 오류인 줄 알았습니다.
컨슈머
@PostMapping("/updateStatus")
public boolean updateStatus(@RequestBody Consult consult){
    System.err.println(consult);
    return consultFeign.updateStatus(consult);
}

feign 인터페이스
@PostMapping("/consult/updateStatus")
boolean updateStatus(@RequestBody Consult consult);

인터페이스 공급자
@PostMapping("/updateStatus")
public boolean updateStatus(@RequestBody Consult consult){
    return consultService.updateStatus(consult);
}

왜냐하면 이전에 전달 대상을 호출해도 문제가 없었기 때문에 모든 것을 실체류에서 찾았어요.


import com.fasterxml.jackson.annotation.JsonBackReference;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;


@Entity(name = "docter")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Docter implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer doctorId;

    private String name;

    private Integer renzheng;

    private Integer goods;

    private String img;

    @OneToMany
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "doctorId")
    @JsonBackReference
    private Set consults = new HashSet<>();

}

갑자기 Data 주석에서 toString 방법이 다방면으로 작동하는 데 오류가 있을 수 있음을 발견하였으며, 시도해 보는 태도로 @Data 핸드폰 getset을 삭제한 후에 호출할 수 있습니다.
@Entity(name = "mzy_docter")
public class Docter implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer doctorId;

    private String name;

    private Integer renzheng;

    private Integer goods;

    private String img;

    @OneToMany
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "doctorId")
    private Set consults = new HashSet<>();


    public Integer getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(Integer doctorId) {
        this.doctorId = doctorId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getRenzheng() {
        return renzheng;
    }

    public void setRenzheng(Integer renzheng) {
        this.renzheng = renzheng;
    }

    public Integer getGoods() {
        return goods;
    }

    public void setGoods(Integer goods) {
        this.goods = goods;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public Set getConsults() {
        return consults;
    }
    @JsonBackReference
    public void setConsults(Set consults) {
        this.consults = consults;
    }
}

jpa의 구덩이일지도 몰라요.신의 많은 가르침을 바랍니다..

좋은 웹페이지 즐겨찾기