본문 바로가기

기록하는 중/Spring Boot11

[Spring Boot] "java.util.Map.get(Object)" is null Request processing failed: java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "java.util.Map.get(Object)" is null] with root causeboolean 값이 필요한데 null로 리턴 된다.NullPointerException으로 처리해도 되지만 response.get("result") != null   != null 조건을 추가해서 해결 2024. 11. 15.
[Spring] BeanCreationException: Error org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource 이런 오류가 났는데 원인은? 매핑 경로 중복  의존성 버전 충돌 위의 두가지의 이유로 나는 에러 코드 였다.Controller 에서 살펴 보니 기존 코드를 복사 하면서 메서드 명은 변경을 했는데mapping 경로를 변경하지 않아서 생긴 오류 였다.해결 : 중복된 mapping 경로 변경 !! 2024. 10. 30.
[Spring Boot] Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. 'url' 에러 application.properties에서 drive를 설정하지 않았을 때 Reason: Failed to determine a suitable driver class   해결 방법 @SrpingBootApplication에 (exclude = DataSourceAutoConfiguration.class) 추가 2024. 9. 14.
[Spring] TooManyResultException: Expected one result(or not) to be returned by selectOne(), but found: 3 에러 발생TooManyResultException: Expected one result(or not) to be returned by selectOne(), but found: 31개의 결과만 출력되어야 하는데 3개의 결과가 찾아지는 문제가 발생보통은 list를 할텐데 list는 다른 쿼리로 뽑고 있어서 할 필요가 없었음그래서 서브 쿼리를 select max() from 을 써서 결과가 잘 나오나 봄.ex ) select id, point, charge, email, phone_number from select( max(id), max(point), max(charge), max(email), max(phone_number) from user u  join payment p on  u.id = p.id).. 2024. 3. 2.
[Lombok] 어노테이션 자주 사용하는 어노테이션 어노테이션 설명 @Getter/Setter 코드를 컴파일할 때 속성들에 대한 Getter/Setter 메소드 생성 @ToString toString() 메소드 생성 @ToString(exclude={"변수명"}) 원하지 않는 속성을 제외한 toString() 메소드 생성 @NonNull 해당 변수가 null 체크, NullPointerException 예외 발생 @EqualsAndHashCode equals()와 hashCode() 메소드 생성 @Builder 빌더 패턴을 이용한 객체 생성 @NoArgsConstructor 파라미터가 없는 기본 생성자 생성 @AllArgsConstructor 모든 속성에 대한 생성자 생성 @RequiredArgsConstructor 초기화되지 않.. 2024. 1. 28.
[Spring] tomcat tomcathttps://tomcat.apache.org/ Apache Tomcat® - Welcome!The Apache Tomcat® software is an open source implementation of the Jakarta Servlet, Jakarta Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications. These specifications are part of the Jakartatomcat.apache.org   다운로드  WAS 서버 구축을 위해서 필요보통 C: 아래에 압축을 풀어서 둠   eclipse 설정add 를 누르고 .. 2023. 12. 3.
[@GeneratedValue] 기본키 생성 @GeneratedValue 어노테이션을통한 기본키를 생성하는 전략 생성 전략 설명 GenerationType.AUTO(default) JPA 구현체가 자동으로 생성 전략 결정 ex) GeneratedValue(strategy = GenerationType.AUTO) GenerationType.IDENTITY 기본키 생성을 데이터베이스에 위임 ex)MySql 데이터베이스의 경우 AUTO_INCREMENT를 사용하여 기본키 생성 GenerationType.SEQUENCE 데이터베이스 시퀀스 오브젝트를 이용한 기본키 생성 @SequenceGenerator를 사용하여 시퀀스 등록 필요 GenerationType.TABLE 키 생성용 테이블 사용. @TableGeneratror 필요 2023. 11. 30.
[@Column] 속성 @Column 어노테이션 추가 속성 속성 설명 기본 값 name 필드와 매핑할 컬럼의 이름 설정 ex) @Column(name = "item_id") 객체의 필드 이름 uninque(DDL) 유니크 제약 조건 설정 insertable insert 가능 여부 true updatable update 가능 여부 ture length String 타입의 문자 길이 제약 조건 설정 ex) @Column(length = 50) 255 nullable(DDL) null 값의 허용여부 설정, false 설정 시 DDL 생성 시에 not null 제약조건 추가 ex) @Column(nullable = false) columnDefinition 데이터베이스 컬럼 정보 직접 기술 ex) @Column(columnDefini.. 2023. 11. 30.
[Entity] 어노테이션 엔티티 매핑 관련 어노테이션 어노테이션 설명 @Entity 클래스를 엔티티로 선언 @Table 엔티티와 매핑할 테이블을 지정 @Id 테이블의 기본키에 사용할 속성을 지정 @GeneratedValue 키 값을 생성하는 전략 명시 @Column 필드와 컬럼 매핑 @Lob BLOB, CLOB 타입 매핑(용어 설명 참조) @CreationTimestamp insert 시 시간 자동 저장 @UpdateTimestamp update 시 시간 자동 저장 @Enumerated enum 타입 매핑 @Transient 해당 필드 데이터베이스 매핑 무시 @Temporal 날짜 타입 매핑 @CreateDate 엔티티가 생성되어 저장될 때 시간 자동 저장 @LastModifiedDate 조회한 엔티티의 값을 변경할 때 시간 자.. 2023. 11. 25.