공부/Java와 Spring
-
TIL 174일 - Spring 여러 데이터 소스공부/Java와 Spring 2022. 6. 21. 20:29
https://2dongdong.tistory.com/33 Spring JPA Multiple Databases 설정 Spring JPA – Multiple Databases 1. 다중 DB 설정 시, 알아야 할 것2. 소스코드2-1. Entity2-2. Repository2-3. DB Configuration2-3-1 application.properties2-3-2 Main Datasource2-3-3 Seco.. 2dongdong.tistory.com ㄹㅇ 위에 있는 글 그대로 하면 됨. 진짜 저사람은 신이야. 간만에 하나 조졌다.
-
TIL 163일 - jpa repository 테스트공부/Java와 Spring 2022. 6. 10. 17:21
ExtendWith, DataJpaTest 어노테이션을 달고나서 AutoConfigureTestDatabase 어노테이션을 달아주니 테스트가 된다. AutoConfigureTestDatabase는 jpa 테스트할 때 내부 인메모리 DB가 아닌 실제 DB를 통해 하겠다는 거라고 한다. package com.example.ical; import com.example.ical.Domain.User; import com.example.ical.Infrastructure.UserRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.fa..
-
TIL 158일 - optional 필드 리팩토링 해보기공부/Java와 Spring 2022. 6. 6. 01:50
원래 nullable한 필드가 아래처럼 있었다. private Integer beginDday; private Integer endDday; private Integer beginOrder; private Integer endOrder; 그래서 이런 놈으로 한번 감싸는 필드를 만들어 줬다. package com.trevari.policy.core.Antlr; import lombok.Value; import java.util.Optional; @Value(staticConstructor = "of") public class BeginInfo { Integer dday; Integer order; public Optional getDday() { return Optional.ofNullable(dday);..
-
TIL 157일 - java class optional field공부/Java와 Spring 2022. 6. 4. 21:59
Optional이 생긴 이유 Optional은 필드에 적용하기 위해서가 아니라 메서드의 반환값을 위해 추가가 되었다고 한다. 그 증거로 Optional은 객체의 속성으로 사용할 때 필요한 Serializable을 구현하지 않았다. 근데 그럼 class에서 nullable한 값이 있다면 어떻게 해야할까...? 아래 글을 봤을 땐 일단 명시적으로 할 수는 없고 개별로 null 체크를 하는 수밖에 없다 같은 식으로 말을 한다. https://sungminhong.github.io/java/optional/ [JAVA] Optional을 필드에서 몰아내자! 글을 쓰게 된 이유 회사에서 코드리뷰를 하면서 Optional 사용법에 관한 논의가 있었습니다. :flushed: 기록을 위해 쓰면서도 혹시 도움이 되실 분..
-
TIL 150일 - 짧짧 build gradle공부/Java와 Spring 2022. 5. 28. 19:58
spring 관련된 build.gradle을 보면 회사의 어떤 프로젝트들은 버전이 없는데 잘 돌아가는 것을 본 적이 있다. 그래서 똑같이 복사해서 써봤더니 나는 안됐음... 이유를 보니 https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/ Dependency Management Plugin Gradle’s maven and maven-publish plugins automatically generate a pom file that describes the published artifact. The plugin will automatically include any global dependency management..
-
TIL 148일 - 진짜 열받아 죽을뻔 한 멀티 모듈 repository공부/Java와 Spring 2022. 5. 27. 00:13
... 결론만 말하면 뻘짓을 한 거 같다. 아니 왜 안되냐고? 회사에 있는 doamin안의 엔티티 코드에는 엔티티나 ID, NotNull 같은 어노테이션이 붙어있지 않았다. 그래서 그냥 똑같이 구현을 했는데... 아마도 그건 때문에 에러가 생긴 것 같다. 그냥 아래처럼 만들어 주니까, 뭐 컴포넌트 스캔이고 나발이고 필요 없이 그냥 동작한다.... package com.trevari.policy.core; import org.jetbrains.annotations.NotNull; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax...