토이 프로젝트를 위해 서버를 여러 대 만들어 사용하다 보니 키페어도 여러 개가 생겼다. id_rsa1, id_rsa2 같은 방식으로 여러 개를 만들어 사용했더니 시간이 지나면서 어느 서버에 접속하는 키인지 잊어버리게 되었다. 다른 사람들은 어떻게 여러 개의 키 페어를 관리하는지 찾아봤다. 키 페어란?보안 목적으로 사용되는 두 개의 암호화 키, 즉 공개 키(public key)와 비밀 키(private key)를 의미합니다.키 페어의 구성 요소는 공개키와 비밀키가 있으며, 공개키는 클라우드 인스턴스에 업로드 되고, 비밀키는 로컬에 안전하게 보관하고, 접근 권한을 제한해야 합니다. 일반적으로 .pem, .key와 같은 확장자를 가진 파일에 저장된다. config 파일에 별명-키로 관리 하기1. ~/.ssh ..
Redis에 데이터를 직렬화/역직렬화 처리할 때 SerializationException이 발생 아래와 같이 직렬화, 역직렬화 대상이 되는 클래스에 LocalDateTimeSerializer, LocalDateTimeDeserializer를 각각 지정해서 직렬화, 역직렬화에 사용한다. @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) private LocalDateTime createdDate; @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateT..
장점 실제 Apache Tomcat을 이용해서 테스트한다. 전 구간을 테스트한다. 내부 구현이나 기술을 검증하기 보다 시나리오를 기반으로 검증한다. 단점 아래와 같은 구성이 필요하며 MockMvc와 비교해서 속도가 느리다. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class AcceptanceTest { @LocalServerPort int port; @BeforeEach public void setUp() { RestAssured.port = port; } ... } 사용 방법 GET 요청 예) private ExtractableResponse 지하철_노선_목록_조회_요청() { return Re..
패키지 사이에 의존성을 낮추는 방법 절차지향 로직 사용할 패키지에 인터페이스를 만들고 구현은 도메인에 해당하는 패키지에서 구현 도메인 이벤트 퍼블리싱 도메인 이벤트 퍼블리싱이란? 패키지 사이에 결합도를 낮추기 위해 사용 도메인이 이벤트를 생성하면 이벤트 디스패처가 리스너에게 전달 어떤 동작 이후에 연관된 동작을 요청할 때 사용 ex) 식사를 마친 테이블에 계산이 끝나면 테이블 상태를 변경한다. 구현 방법 Spring Framework에서 제공하는 기능으로 구현하는 방법 Spring Data JPA에서 제공하는 기능으로 구현하는 방법 Spring Data JPA의 이벤트 구현 예제 & 전체 소스 Publisher // 이벤트로 전달할 형식 public class SpringEventPublisher { p..
생성 과정 요약 VPC 생성 Subnet 생성 Internet Gateway 연결 생성 및 VPC에 연결 Route Table 생성 외부망에서 사용할 라우팅 테이블 생성 모든 요청이 Internet Gateway를 거치도록 설정 외부망에서 사용할 서브넷 등록 내부망에서 사용할 라우팅 테이블 생성 내부망에서 사용할 서브넷 등록 NAT 게이트웨이 모든 요청이 NAT 게이트웨이를 거치도록 설정 서버 생성 외부망에서 웹 서비스 용도의 EC2 생성 페어 키 생성 Security Group 설정 : 전체 대역 8080번 포트 오픈, 관리망 22번 포트 오픈 내부망에서 데이터베이스 용도의 EC2 생성 Security Group 설정 : 외부망 3306번 포트 오픈, 관리망 22번 포트 오픈 관리망에 베스쳔 서버 용도..
JPA의 장점 객체에 적절한 책임을 할당하는 객체지향적 개발이 가능하다. 새로운 필드가 추가될 때마다 쿼리를 수정해야 하는 문제가 발생하지 않는다. 생성 방식 create: 기존 테이블 삭제 후 다시 생성 (개발) create-drop: create와 같으나 종료 시점에 테이블 drop (개발) update: 변경된 부분만 반영 (테스트, 개발) validate: entity와 table이 정상 매핑되었는지만 확인 (테스트, 운영) none: 사용하지 않음 (스테이징, 운영) 데이터베이스 스키마 생성 방식 설정 // application.properties spring.jpa.hibernate.ddl-auto={생성_방식} 스키마 자동 생성을 위한 Entity class 작성법 @Entity // (1)..
정적 팩토리 메소드란? 생성자를 통해 객체를 생성하는 것이 아닌 메서드를 통해 객체를 생성하는 것을 정적 팩토리 메서드라고 한다. 인스턴스 캐싱과 함께 사용하여 매번 새로운 인스턴스를 생성하지 않을 수 있다. 인스턴스 캐싱이란? 인스턴스를 미리 만들어 두고 필요할 때 사용함으로서 메모리 낭비를 해결하는 방법이다. public class LottoNumber { // 인스턴스 캐싱 private static final Map lottoNumbers = new HashMap(); // 1부터 45까지 LottoNumber 객체를 미리 생성한다. static { for (int number = LOTTO_START_NUMBER; number
디미터의 법칙(Law of Demeter) 상태를 가지는 객체의 데이터를 꺼내려 하지 말고 메세지를 보내라. 객체의 자료를 숨기고 함수를 공개함. 코드의 중복 사용 방지와 유지 보수성을 높일 수 있다. 결합도를 낮추고 응집도를 높일 수 있다. 디미터의 법칙을 위반한 경우 public class Lotto { private List LottoNumbers; public Lotto(List lottoNumbers) { LottoNumbers = lottoNumbers; } public List getLottoNumbers() { return LottoNumbers; } } @Test void 디미터의_법칙_위반() { List lottoNumbers = new ArrayList(Arrays.asList(1,..
리뷰어에게 코드 컨벤션을 지적받고 함께 받은 우아한테크코스 스타일 가이드를 읽어보았지만 사용 예시가 없어서 글로만 이해하기 힘들었다. 그리고 이때까지 함께 첨부된 intellij-java-wooteco-style.xml의 쓰임세에 대해 알지 못했다. 나는 사용 예시와 함께 정리된 글이 있지 않을까? 하고 검색했는데 IntelliJ에 Google Java Style Guide 적용하기 (feat. Naver)를 읽고 함께 첨부된 xml 파일의 용도를 알 수 있었다. 인텔리제이에서 자동 정렬(⌥ + ⌘ + L)을 사용하면 Wooteco Java Code Style로 자동 정렬 하도록 인텔리제이 설정을 바꿀 수 있다. IntelliJ에서 Wooteco Java Style Guide 사용하기 우아한테크코스 스타..
커밋 메세지 형식 (): 커밋 메세지의 행은 100자를 초과할 수 없다! 이를 통해 다양한 git 툴뿐만 아니라 github에서도 메세지를 쉽게 읽을 수 있다. Subject Line 변경에 대한 간결한 설명이 포함되어야 함. 허용된 feat (feature) fix (bug fix) docs (documentation) style (formatting, missing semi colons, …) refactor test (when adding missing tests) chore (maintain) 허용된 변경된 부분이라면 무엇이든 지정될 수 있다. 예를 들어 $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView 등... 생략 가능하다...