728x90 전체 글86 Spring boot 통합 Test @SpringBootTest > @SpringBootApplication을 찾아가서 모든 BeanScan진행 @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK) * junit4 기준 @RunWith와 같이 사용해야함 참고 : https://developing-countries.tistory.com/50?category=1023056 org.junit.runners.model.InvalidTestClassError org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.example.studyspringboot.S.. 2022. 2. 20. Logging 로깅 퍼사드 > 프레임워크를 사용하는 애플리케이션들이 원하는 로거를 사용할 수 있도록 사용 ex) Commons Logging, SLF4j ... * Commons Logging / SLF4j 차이 - Commons Logging의 경우 runtime도중에 클래스 로거에서 로거를 찾음 - SLF4j 의존성 등을 통해 로거를 지정한 후 application 동작 > Spring 5에서 Spring-JCL 모듈을 통해 컴파일 시점에 SLF4j or Log4j2로 전환할 수 있도록 변경됨 > 사실상 SLF4j or Log4j2 둘 다 Logback을 사용해서 log를 찍음 참고 * --trace로 전부 디버깅모드로 log를 출력할 수 있음 * spring.output.ansi.enabled를 통해 컬러출력 가.. 2022. 2. 20. 프로파일 @Profile > 특정 profile에서만 bean 을 등록하고 싶은 경우 > application 동작을 특정 profile에서 bean설정을 다르게 하고 싶은 경우 사용 * application.properties > spring.profiles.active에 설정해서 사용 spring.profiles.active=prd * spring.profiles.include 를 통해 생성한 application-{profile}.properties 파일을 추가할 수 있음 spring.profiles.include=fullname > 이후 application-fullname.properties 생성 후 정의 * application-{profile}.properties 파일이 우선순위가 더 높아서 appl.. 2022. 2. 20. Properties 관리 @ConfigurationProperties 1. 클래스 정의 @ConfigurationProperties("sangguk") @Component @Data public class SangGukProperties { private String name; private int age; private String fullName; } * 클래스 정의 후 빌드 시 application.properties에서 자동완성으로 사용 가능 2. properties 정의 sangguk.name=SangGuk sangguk.age=${random.int(0,100)}//random.int(범위) 란듐 sangguk.full-name=PackSangGuk * 범위에 공백이 있으면 안되며 properties 내에서는 모두 문.. 2022. 2. 14. 이전 1 ··· 6 7 8 9 10 11 12 ··· 22 다음 728x90