HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🚀
Random Bit Flip
/
🐶
[2기 - 흑구] 4주차 RBF
🐶

[2기 - 흑구] 4주차 RBF

주차
SpringBoot Part2
회고일
Apr 15, 2022
참여자
멘토
Property
tag
문정현
  • parseInt 대신 getInteger를 쓰는 실수
    • → getInteger는 시스템 프로퍼티명을 입력 받아서 시스템 프로퍼티 값(정수값)을 반환하기 때문에 해당하는 프로퍼티명이 존재하지 않는 경우 null을 반환해준다.
      public class IntegerGetIntegerExample2 { public static void main(String[] args) { // set a custom property System.setProperty("test.integer", "100"); // get the value of the custom property we set System.out.println("Custom Property: " +Integer.getInteger("test.integer")); } }
  • 1주차 과제 관련
    • FileRepository에서 의존하는 파일 이름 매개변수를 @Value를 이용해 필드 변수로 주입받으면 생성자에서 파일을 로드할 때 파일 이름이 바로 주입되지 않고 null로 되는 문제 발생
      • → 생성자의 매개변수 안에 @Value를 사용해서 주입받는 방식으로 문제 해결
        //문제: @Value로 필드 주입했지만 null이 반환되어 있음 public class FileVoucherRepository implements VoucherRepository { @Value("${voucher_info}") private String fileName; private Map<UUID, Voucher> map = new ConcurrentHashMap<>(); public FileVoucherRepository() { try { this.fileName = fileName; loadFile(fileName); } catch (Exception e) { } } } //해결: @Value를 생성자 매개변수로 삽입 public class FileVoucherRepository implements VoucherRepository { private String fileName; private Map<UUID, Voucher> map = new ConcurrentHashMap<>(); public FileVoucherRepository(@Value("${voucher_info}") String fileName) { try { this.fileName = fileName; loadFile(fileName); } catch (Exception e) { } } }
    • 안 쓰는 import를 제거하지 않은 코드에 대한 자동 배포 시 문제가 발생할 수 있기 때문에 자동으로 제거해야 한다.
      • [Intellij / 인텔리제이] 안쓰는 import 제거 하는 방법
        방법1. 단축키로 삭제(Ctrl+Alt+o) ​ 방법2. auto import 옵션에서 자동으로 삭제 되게 기능 ON [출처] [Intellij] 자동으로 안쓰는 import 삭제방법|작성자 codegun blog.naver.com/PostView.nhn?blogId=cute..
        [Intellij / 인텔리제이] 안쓰는 import 제거 하는 방법
        https://milenote.tistory.com/25
        [Intellij / 인텔리제이] 안쓰는 import 제거 하는 방법
    • Spring, Java 관련 신뢰성 있는 자료 출처 ← 흑구님 추천
      • www.baeldung.com
        https://www.baeldung.com/
        DZone Java
        Java programming news and training resources from DZone, the trusted source for learning advanced software design, web development and devops best practices.
        DZone Java
        https://dzone.com/java-jdk-development-tutorials-tools-news
        DZone Java
        Learn Spring Tutorial - javatpoint
        This spring tutorial provides in-depth concepts of Spring Framework with simplified examples. It was developed by Rod Johnson in 2003. Spring framework makes the easy development of JavaEE application. It is helpful for beginners and experienced persons. Spring is a lightweight framework.
        Learn Spring Tutorial - javatpoint
        https://www.javatpoint.com/spring-tutorial
        Learn Spring Tutorial - javatpoint
정해민
  • @ConfigurationProperties 사용 시에 immutable 필드로 설정하는 방법
    • 스프링부트 2.2 버전부터 @ConstructorBinding 애노테이션을 사용해서 setter가 아닌 생성자를 통해 값을 바인딩 할 수 있다.
      • Immutable @ConfigurationProperties
        Using similar approach to the one from https://stackoverflow.com/a/60442151/11770752 But instead of AllArgsConstructor you can use the RequiredArgsConstructor. Consider following applications.properties myprops.example.firstName=Peter myprops.example.last-name=Pan myprops.example.age=28 Note: Use consistency with your properties, i just wanted to show-case that both were correct ( fistName and last-name).
        Immutable @ConfigurationProperties
        https://stackoverflow.com/questions/26137932/immutable-configurationproperties
        Immutable @ConfigurationProperties
 
최현웅
  • 로그관리 : 데이터독
  • 래퍼클래스와 프리미티브타입 오토박싱 사용하지 않기.
  • UUID와 Auto increment 차이.