분류 전체보기
-
[SpringBoot] Dependency Injection 순서에 대해서카테고리 없음 2022. 11. 22. 14:01
Spring Dependency Injection 순서에 대해서 Spring boot 에서 Bean 을 주입 받을 때 그 순서를 잘 모르고 있었는데, 이번 기회에 정리해 보자. Service 레이어에서 여러 서비스에 대한 디펜던시를 주입받는 상황을 가정하여 밑과 같은 테스트 프로젝트를 생성하였다. @Service public class MainService { private final ConstructorService constructorService; private SetterService setterService; @Autowired private AutowiredService autowiredService; public MainService(ConstructorService constructorSe..
-
[Spring Boot] Field Injection 을 추천하지 않는 이유개발 2022. 11. 22. 13:57
Dependency Injection 방법 세가지와 왜 @Autowired 로 필드 인젝션이 추천되지 않는가? Dependency Injection 3가지 방법 Field Injection Setter Injection Constructor Injection 1. Field Inejction 변수 선언부에 @Autowired Annotation을 붙인다. @Component public class SampleController { @Autowired private SampleService sampleService; } 그런데 이 필드 주입은 추천 되는 방법이 아니다. 이 외에 이후에 소개 될 Constructor Injection 을 더 추천하는데, 왜 그럴까? 1.1 Field Injection 을 사..
-
[DB] DB 조인 방식 3가지개발 2022. 1. 23. 16:42
물리적 Join 의 종류 Driving Table 과 Driven Table Join 시 먼저 액세스 되는 테이블과 아닌 테이블 Driving Table: 먼저 액세스 됨 Driven Table: 나중에 액세스 됨 Driving Table 은 DB 옵티마이저가 결정한다. DB Join의 방식 (물리적) Nested Loop Join https://coding-factory.tistory.com/756 2개 이상의 테이블에서 Driving Table 을 기준으로 Driven Table 을 스캔하여 결과를 서칭하는 것. 인덱스에 의한 랜덤 액세스에 기반하고 있으므로, Driving Table 서치 결과가 많을 수록 성능이 나빠짐. Driven Table 에는 조인을 위한 인덱스가 있어야만 한다. 이 때 Dr..
-
나는 생계형 개발자가 되고싶은가, 아니면 성장형 개발자가 되고싶은가?잡담 2022. 1. 7. 10:53
나는 생계형 개발자를 하고 싶은 건가 아니면 성장형 개발자(개쩌는 개발자!)를 하고 싶은 건가?생각보다는 모두가 일을 ‘잘’ 하고 싶어 하지는 않는 다는 것을 알게 되었다.일은 일일 뿐, 직장은 직장일 뿐이고 그 외에서 삶의 즐거움을 찾는 사람이 많다는 것이다. 내가 대학교 4학년때 교수님의 온라인 첫 수업에서 자기 소개 에세이를 제출했는데, 그 에세이에서 그런 말을 했었다.저는 이제 더 이상 내가 반드시 ‘열정’ 을 가지고 할 수 있는 일을 찾지 않기로 했다. 난 생각보다 일상의 행복에 만족하는 사람이었고, 일 외에 다른 곳에서 내가 행복할 방법을 찾겠다. 나는 생계형 개발자로 시작했다. 애초에 내가 개발자가 되기로 선택한 이유가 외국에 살고 싶었기 때문이고, 그 중 오피스 잡을 구할 수 있는 방법중 ..
-
[JPA] bulk data batch 작업 시 유의점개발 2022. 1. 6. 15:58
JPA 벌크 데이터 작업 시 유의점 JPA 의 벌크성 작업은 영속성 컨텍스트와 무관하다. 기존 엔티티 수정 메커니즘 JPA 는 엔티티를 영속성 컨텍스트에 보관한 후, DB에 반영한다. 이 때 최초상태를 복사해서 저장해두고, 플러시 시점에서 스냅샷과 엔티티를 비교하여 변경사항만을 DB 에 반영한다. 기존 엔티티 수정 메커니즘은 다음과 같다. 트랜잭션을 커밋하기 전, 엔티티 매니저 내부에서 flush() 를 먼저 호출한다. 엔티티와 스냅샷을 비교해서 변경 지점을 찾는다. 변경사항이 있는 경우 쓰기지연 SQL 저장소에 SQL 문을 생성해서 저장해 둔다. DB에 비로소 commit 될 때, SQL Query 를 DB로 보내서 실제로 반영한다. 벌크 수정 메커니즘 그러나 벌크 작업은 앞서 설명했던 것처럼 영속성 ..
-
[CI] Jenkins 와 Github Webhook 으로 PR 유효성 체크하기개발 2021. 12. 29. 18:06
"CI"는 개발자를 위한 자동화 프로세스인 지속적인 통합(Continuous Integration)을 의미합니다. CI를 성공적으로 구현할 경우 애플리케이션에 대한 새로운 코드 변경 사항이 정기적으로 빌드 및 테스트되어 공유 리포지토리에 통합되므로 여러 명의 개발자가 동시에 애플리케이션 개발과 관련된 코드 작업을 할 경우 서로 충돌할 수 있는 문제를 해결할 수 있습니다. 보통 코드를 개발한 뒤 원격 서버에 배포를 하기 위해서는 다음과 같은 과정을 거친다. 각 단계에서 개발 툴들이 어떤 역할을 하는지는 여기를 체크하자. 이 포스팅에서는 오로지 CI 에 대해서만 다룬다. 코드를 지속적으로 통합하기 위해서는 개발자가 각자 로컬에서 작업한 코드 변화에 대해서 시스템 안정성이 보장되느냐가 매우 중요하다. 특히 어..
-
[JPA] Primary Key가 아닌 필드를 참조하는 Foreign Key 를 만들때개발 2021. 12. 12. 17:27
Primary Key가 아닌 필드를 참조하는 Foreign Key 를 만들때 @JoinColumn(referencedColumnName = [참조하는 필드 이름]) 오류 상황 Stock 이라는 테이블과 DailyStock 이라는 데이터 필드의 일대다(1:N) 매칭 시 일어난 문제이다. Price 는 Stock 의 tickerSymbol 이라는 필드를 참조하고 있다. Price @Entity public class Price { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "price_id") private Long priceId; @ManyToOne @JoinColumn(name = "ticker_symbol") priva..
-
[TDD] TDD 로 알고리즘 문제 풀어보기 - 프로그래머스 42626, 더 맵게개발 2021. 10. 31. 17:57
TDD 로 알고리즘 문제 풀어보기 - 프로그래머스 42626 단기적인 목표로는 Spring Reactive 앱을 TDD 로 구현하는 것이 목표이다. 그런데 TDD 개발 자체가 손에 익지 않아서 처음부터 적용하기에는 무리가 있다. 알고리즘 코딩테스트 문제들은 input 과 output 의 명세가 명확하다. 따라서 tdd 연습에 매우 적합하다고 생각했다. 프로그래머스 42626 번 문제 문제 분석 문제의 핵심은 가장 작은 숫자와 두번째로 작은 숫자를 계속 섞다가, 더이상 섞을 수 없는 지점을 정의하는 것이다. 따라서 먼저 함수의 테스트가 필요한 경우의 수를 잘게 쪼개서 리스트업 해보았다. 테스트 조건 가장 작은 원소를 똑바로 고르는가 두번째로 작은 원소를 똑바로 고르는가 1, 2의 결과를 섞을 때 올바른 연..
-
[Spring Boot] Logging 과 @slf4j 에 대해서개발 2021. 10. 29. 23:50
logging-slf4j.md 가장 간단한 방법 System.out.println() 을 이용하기 로그의 양이나 로그 레벨을 조절 할 수 없다. 출력된 로그를 파일 등에 저장하기 불편하다 느리다. 1) java.util.logging JDK 1.4 부터 포함된 표준 로깅 API 2) Apache Commons logging 3) Log4j 4 SLF4J - logging Facade(퍼사드) SLF4J 는 로깅 퍼사드임. 로깅에 대한 추상 레이어를 제공하는 interface 왜 쓰는가? 어플리케이션은 SLF4J 를 사용해서 어떤 로깅 라이브러리를 쓰더라도 같은 방식으로 로그를 남겨야함 로그 라이브러리를 교체하더라도 코드 변경 불필요 4) Logback 로깅 퍼사드의 구현체 중 하나임 이점 오랫동안 검증 ..