전체 글
-
Instant vs LocalDateTimeJava 2023. 5. 27. 00:01
LocalDateTime, Instant란? 공통적으로 시간을 관리하기 위해 사용하는 자바 클래스입니다. 개인 프로젝트를 진행하면서 Date 더 나아가 Java8의 LocalDate를 사용하곤 합니다. Instant란? Instant란 의미는 순간, 즉시를 의미합니다. (인스턴스 음식을 떠올리면 좋습니다) long 형태로 Unix Tiemstamp를 저장하기 때문에 연산이 빠릅니다. (인간보다는 기계친화적) Instant.now()로 현재 순간을 기준으로 클래스를 생성할 수 있으며 출력해 보면 다음과 같은 형태로 보이게 됩니다. 2023-04-11T11:35:11.301031Z 나노초까지 표현이 가능하며 뒤에 Z를 표현합니다. (Z는 UTC를 의미합니다.) 자세한 사항에 대해서는 날짜/시간과 관련된 국제..
-
Postman대신 IntelliJ로 Http 테스트하기IntelliJ 2023. 5. 26. 00:01
개요 항상 Postman을 활용하여 Http 테스트를 수행하였습니다. 하지만 IntelliJ의 Http테스트를 활용하게 되면 Http 테스트도 팀원들과 편리하게 공유할 수 있습니다. IntelliJ Http Client Plugins 설치 [그림 1]처럼 Http Client 플러그인을 설치합니다. Http 디렉터리 만들기 [그림 2]와 같이 http 디렉터리를 만들어주고 User.http라는 파일을 만들어 테스트할 Http를 관리할 수 있습니다. 테스트해보기 ### 1. 회원가입 POST localhost:8080/user Content-Type: application/json { "email": "john@email.com" } 회원가입을 위한 테스트입니다. Http Post 요청을 보내고 /user..
-
Kotlin JPA 양방향 연관관계 매핑프로젝트/선착순 쿠폰 발급 시스템 2023. 5. 25. 00:01
연관관계란? 객체와 관계형 데이터베이스의 테이블의 불일치를 해결하기 위해 테이블 간의 연관관계를 매핑할 수 있습니다. 데이터베이스와 객체와의 다른점 데이터베이스는 외래키 하나만으로 양쪽 테이블 조인이 어디에서나 가능합니다. 하지만 객체는 참조용 필드가 있는 객체만 다른 객체를 참조하는 것이 가능합니다. 예를 들어 Account에 Member 프로퍼티가 존재하면 Account에서 Member를 조회할 수 있습니다. JPA를 사용하여 데이터베이스와 패러다임을 맞추기 위해서 객체는 단방향 연관 관계를 가질지, 양방향 연관 관계를 가질지 선택해야 합니다. 양방향과 단방향 양방향은 기본적으로 단방향 참조 2개로 구성됩니다. 처음에는 외래키를 가진 쪽(연관관계의 주인)에 단방향으로 연관관계를 매핑하고 필요시에 양방..
-
Kotlin Jpa Auditing - Entity 수정, 생성기간 저장프로젝트/선착순 쿠폰 발급 시스템 2023. 5. 24. 00:01
BaseEntity 정의 @MappedSuperclass @EntityListeners(AuditingEntityListener::class) abstract class BaseEntity { @CreatedDate @Column(nullable = false, updatable = false) var createdAt: LocalDateTime = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()) @LastModifiedDate @Column(nullable = false) var modifiedAt: LocalDateTime = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())..
-
AWS VPC란?AWS 2023. 5. 23. 00:01
VPN이란? Virutal Private Network의 약자로 가설사설망을 뜻합니다. 예를 들어 회사 네트워크에서만 접속 가능한 서버를 집에서 접속하기 위해서 VPN을 이용하여 마치 회사 내부 네트워크에 있는 것처럼 만들어 주는 역할을 수행합니다. 회사 네트워크가 같이 구성되어 있고 보안상 이유로 직원간 네트워크를 분리하고 싶다면 인터넷 선공사를 다시 해주어야 합니다. 이때 VPN을 활용하면 네트워크A와 네트워크 B가 실제로 같은 네트워크상에 있지만 논리적으로 다른 네트워크인 것처럼 동작합니다. VPC란? Virtual Private Cloud의 약자로 가상 네트워크를 의미합니다. VPC를 활용하여 외부와 격리된 네트워크 컨테이너를 생성할 수 있습니다. IP 주소 범위 선택, 서브넷 생성, 라우팅 테이..
-
Mapstrcut 변환시 함수 호출하기Kotlin 2023. 5. 22. 00:01
개요 Mapstruct를 사용하여 SignUpRequest -> SignUpUser로 변환 시 userId 부분에 IDGenerator 함수를 호출하여 변환하고자 합니다. SignUpRequest data class SignUpRequest( @get:JsonProperty("userName", required = true) val userName: kotlin.String, @field:Valid @get:JsonProperty("mobileCarrier", required = true) val mobileCarrier: MobileCarrierType, @get:Pattern(regexp="^[\\d]*$") @get:Size(min=11,max=11) @get:JsonProperty("mobileN..
-
Kotlin MapStruct 사용하기프로젝트/선착순 쿠폰 발급 시스템 2023. 5. 21. 00:01
MapStruct란? 컴파일 시 매핑 코드를 생성하며 Java Bean 간의 매핑을 단순화하는 Java 기반 코드 생성도구입니다. MapStruct를 사용하면 객체 간 데이터 매핑을 위해 boilerplate code를 작성할 필요가 없어집니다. ModelMapper와의 차이점 reflection을 사용하여 객체 간의 필드를 매핑하는 Java 기반 코드 생성도구입니다. 컴파일 시 매핑 코드를 생성하지 않으며, reflection을 사용하기 때문에 MapStruct보다 속도가 느릴 수 있습니다. Kotlin DSL Gradle MapStruct 적용 plugins { kotlin("kapt") version "1.7.10" } subprojects { apply(plugin = "kotlin-kapt") ..
-
Spring Data Redis TTL설정하기프로젝트/선착순 쿠폰 발급 시스템 2023. 5. 20. 00:01
TTL이란? 컴퓨터 네트워킹 및 데이터베이스 시스템에서 사용되는 용어인 "Time To Live"의 약자입니다. 데이터 레코드 또는 네트워크 패킷이 삭제되거나 만료된 것으로 간주되기 전에 존재할 수 있는 시간을 나타냅니다. 예를 들어, Redis 데이터베이스에서 키에 대한 TTL 값을 설정하면 지정된 시간이 경과한 후 해당 키가 데이터베이스에서 자동으로 삭제되도록 할 수 있습니다. 이는 메모리 사용량을 관리하고 오래되거나 오래된 데이터가 데이터베이스에서 자동으로 제거되도록 하는 데 유용합니다. 네트워킹에서 TTL은 패킷이 삭제되기 전에 패킷이 통과할 수 있는 최대 홉(라우터) 수를 지정하는 패킷의 IP 헤더에 있는 필드입니다. 패킷이 통과하는 각 라우터는 TTL 필드를 1씩 감소시키며, TTL 필드가 0..