본문 바로가기

Java

(29)
[오류] HttpMessageNotReadableException : Required request body is missing DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity ... 경로...Controller.deleteEntity(java.util.Map)] 프론트 쪽에서 아래의 함수로 서버에 요청을 보내고 export const deleteEntityApi = async (param) => { const response = await api.delete(`ent/${param}`); return response.data; } ** ..
[오류 / JPA] dentifier of (엔티티) an instance of Entity was altered from A to B identifier of an instance of (Entity) was altered [dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.orm.jpa.JpaSystemException: identifier of an instance of (엔티티) was altered from ( A ) to ( B ) with root cause 본질적으로는 JPA 영속성 관련 문제인데, (JPA에서는 객체들을 우선 영속성 컨텍스트에 등록(flush) 후에 db에 반영한다(commi..
[오류 / JPA] Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table ['(테이블명)'] ( SchemaManagementException 오류 ) JPA 에서는 db테이블과 엔티티를 매핑해줘야 하는데, 이 때 테이블을 인식하지 못해서 발생한 오류. 원래는 @Table(name = "테이블명") 이렇게만 써줬는데, schema를 명시해주지 않아서, 테이블을 인식하지..
[오류] JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.util.Map<java.lang.String,java.lang.Object>>` from Object value (token `JsonToken.START_OBJECT`) JSON parse error: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) 데이터 타입 불일치 오류. => Postman에서 보내는 parameter의 데이터 타입을 잘못 써줘서 났던 오류였다. ( [ ] 괄호를 빼먹음 ) 컨트롤러에서 parameter를 List 타입으로 받아줬기 때문에 아래처럼 보내줘야 한다. ** Postman에서 쌍따옴표("")를 사용해야 오류가 안남. [ {"id" : "testId", "name" : "testNm"}, {"id" : "testId2", "name" : "testNm2"} ] 프론트에서 데이터를 json형태로 서버로 ..
[오류] No primary or single unique constructor found for interface java. No primary or single unique constructor found for interface java. => controller에서 @PutMapping으로 메소드를 실행했는데, @RequestBody / @ResponseBody 어노테이션을 빼먹어서 났던 오류. 제발 이런 오류는 안나게 하자!!!!!!!!!!!!!!!
[Java/Spring] JPA / JPA 어노테이션 / JpaRepository 인터페이스 * JPA ( Java Persistence API ) 객체와 관계형 데이터베이스를 관리하기 위한 자바의 표준 ORM 프레임워크. Hibernate, EclipseLink, OpenJPA 등과 같은 구현체를 사용하여 실제 작업 수행. SQL에 의존하지 않고 데이터에 접근할 수 있으며, 객체 중심 개발 가능. JPQL( Java Persistence Query Language ), Criteria API 지원. * Spring Data JPA JPA를 기반으로 한 Spring 프레임워크의 라이브러리. * ORM (Object-Relation Mapping) : 객체와 데이터베이스 테이블 간의 매핑. [ JPA 어노테이션 ] JPA에서는 entity를 사용하여 객체와 데이터베이스 테이블과의 매핑을 정의하는데..
[Java/intelliJ] Serializable 인터페이스 / 객체 직렬화 & 역직렬화 * Serializable 인터페이스 ( java.io ) 객체를 파일로 저장하거나 다른 서버로 전송할 수 있도록 JVM에 알리는 역할. ( 직렬화* ) 메서드가 없는 마커 인터페이스 (marker interface). package java.io; public interface Serializable { } 해당 객체의 클래스에 Serializable 인터페이스를 구현해주면 된다. import java.io.Serializable; public class exampleClass implements Serializable { private static final long serialVersionUID = 1L; // 직렬화 호환성을 위한 UID ....... } * SerialVersionUID 객체를 ..
[Java] Lombok @ 어노테이션 * Lombok Java 코드 작성을 도와주는 라이브러리. 어노테이션 기반으로 코드 자동생성. https://www.daleseo.com/lombok-popular-annotations/ [자바] 자주 사용되는 Lombok 어노테이션 Engineering Blog by Dale Seo www.daleseo.com [ Lombok 어노테이션 ] - @Getter, @Setter 클래스 필드에 대한 getter / setter 메서드를 자동 생성. - @Data @Getter, @Setter, @ToString, @EqualsAndHashCode, @RequiredArgsConstructor 를 자동 적용. - @NoArgsConstructor 파라미터가 없는 기본 생성자 자동생성. - @AllArgsCon..