본문 바로가기

Java, Kotlin, Spring/Spring, Spring Boot53

[Spring Boot] 13 - Web Application 개발 Spring Boot 013 - Web Application 개발 7. Developing Web Application Spring Boot는 웹 애플리케이션 개발에 아주 잘 어울립니다. HTTP 서버가 내장된 서버를 Tomcat, Jetty, Undertow, Netty 등 내장 프로그램을 사용해서 만들 수 있습니다. 대부분 웹 애플리케이션은 spring-boot-starter-web으로 실행할 수 있습니다. reactive web 애플리케이션은 spring-boot-webflux 모듈을 사용할 수 있습니다. 7.1 Spring Web MVC Framework Spring Web MVC 프레임워크(간단히 Spring MVC라고 부릅니다.)는 "모델 뷰 컨트롤러" 웹 프레임워크입니다. @Controlle.. 2020. 4. 7.
[Spring Boot] 12 - 커스텀 로그 설정 Logback Spring Boot 012 - 커스텀 로그 설정 logback 스프링 프로파일 사용 4.6 Custom Log 설정 다양한 로깅 시스템은 classpath에 있는 적절한 라이브러리를 포함시켜 활성화시킬 수 있습니다. 루트 classpath 또는 logging.config 위치에 명시하여 적절한 설정을 커스터마이징 할 수 있습니다. org.springframework.boot.logging.LoggingSystem 에 원하는 시스템을 명시합니다. 그렇게 권장하진 않습니다. 로깅은 ApplicationContext 가 생성되기 전에 초기화됩니다. 따라서 @Configuration 파일의 @PropertySoruce 로부터 로깅을 제어할 수는 없습니다. 로깅 시스템을 제어할 수 있는 유일한 방법은 시스템 p.. 2020. 4. 1.
[Spring Boot] 11 - 프로파일, 로깅 설정 Spring Boot 011 - 프로파일, 기본 로깅 3. Profiles Spring 프로파일은 어플리케이션 설정의 일부를 분리하고, 특정 환경에서만 작동하게 만드는 방법을 제공합니다. @Component, @Configuration, @ConfigurationProperties 는 로드될 때 제한시키기 위해@Profile로 표시될 수 있습니다. @Configuration(proxyBeanMethods = false) @Profile("production") public class ProductionConfiguration { // ... } spring.profiles.active, Environment 속성을 이용해서 무슨 프로파일이 활성화되었는지 정할 수 있습니다. Command Line Argu.. 2020. 3. 31.
[Spring Boot] 10 - @ConfigurationProperties 사용법 Spring Boot 010 - @ConfigurationProperties 의 여러 장점, 일부 단점 2.8.5 Third-party Configuration 클래스를 주석(annotate)하기 위해 @ConfigurationProperties 를 사용하는 것 뿐 아니라, @Bean 메소드에서도 사용할 수 있습니다. 건드릴 수 없는 클래스가 있을 때, ​ 즉, @ConfigurationProperties("whiteship") @Component public class WhiteshipProperties { } 라고 클래스 위에 어노테이션을 명시할 수 없을 때, 메인 클래스에 와서 public class Application { @Bean @ConfigurationProperties("whiteship.. 2020. 3. 29.
[Spring Boot] 9 - YAML 사용법 Spring Boot 009 - YAML 사용하기 2.7 속성 대신 YAML 사용하기 YAML(야믈, 와이엠엘(.yml))은 JSON의 상위집합(superset)으로, 계층적 뼈대 구조를 설정하는데 편리한 형식(format)입니다. SpringApplication은 classpath에 있는 SnakeYAML library를 가지고 있을 때, 속성(properties)의 대안으로 자동적으로 YAML을 지원합니다. spring-boot-starter는 가장 기본적인 라이브러리고, 이것이 있으면 SnakeYAML 은 자동으로 제공됩니다. 2.7.1 Loading YAML YAML 리스트는 [index] 역참조형으로 표현될 수 있습니다. my: servers: - dev.example.com - another... 2020. 3. 29.
[Spring Boot] 8 외부 설정(Externalized Configuration) Spring Boot 008 - 프로퍼티와 각종 외부 설정의 우선 순위 2. 외부 설정(Externalized Configuration) Spring Boot는 현재 설정을 밖으로 내보낼 수 있어서, 이를 통해 다른 환경에서 같은 설정을 구현할 수 있습니다. properties files YAML files 환경 변수 명령줄 아규먼트 Spring Boot는 PropertySource 순서를 따르며 설정 파일 우선순위를 정할 수 있습니다. devtools 이용시$HOME/.config/spring-boot 폴더 안에서 Devtools 전역 설정 속성 @TestPropertySource @SpringBootText 명령줄 아규먼트 SPRING_APPLIATION_JSON 으로부터의 속성 ServiceConf.. 2020. 3. 28.
[Spring Boot] 7 SpringApplication 커스터마이징 Spring Boot 007 - SpringApplication 커스터마이징, Admin 1.7 웹 환경 SpringApplication 은 사용자 대신 ApplicationContext의 적절한 타입을 생성합니다. WebApplicationType은 다음 룰로 정해집니다. Spring MVC가 존재하면 AnnotationConfigServletWebServerApplicationContext를 사용 Spring MVC가 존재하지 않고, Spring WebFlux가 존재하면 AnnotationConfigReactiveWebServerApplicationContext 를 사용 그렇지 않으면, AnnotationConfigApplicationContext를 사용합니다. 예를 들어 Reactive 타입의 웹 .. 2020. 3. 26.
[Spring Boot] 6 - 배너, SpringApplication 스프링 공식 문서와, 이를 해설해 준 백기선 유투브를 참고 하였습니다. 링크는 맨 아래 있습니다. public static void main(String[] args) { SpringApplication.run(MySpringConfiguration.class, args); } INFO 로깅 메시지가 보입니다. INFO 외 로그레벨을 보려면, Log Levels 을 참고합니다. resources 폴더 아래에 application.properties 파일을 생성합니다. logging.level.root=warn logging.level.org.springframework.web=debug logging.level.org.hibernate=error원하는 설정을 입력하면, 로그 레벨을 설정할 수 있습니다. .. 2020. 3. 25.
[Spring Boot] 5 Devtools, restart, reloading Spring Boot 005 - spring-boot-devtools, reloading Spring Boot의 Devtools(Developer Tools)는 개발의 편의를 위한 도구를 지원합니다. 오늘 설명할 내용은 Property 캐싱 설정 자동 재시작(restart) LiveReload(새로고침) Global Settings 원격 애플리케이션 실행 입니다. 8.1 Property 기본값 Spring Boot가 지원하는 몇몇 라이브러리는 성능을 향상하기 위해 캐시를 사용합니다. 예를 들어 template engines 반복적으로 템플릿 파일을 파싱하는 것을 피하기 위해 컴파일된 템플릿을 캐싱합니다. static resource를 서비스할 때 spring MVC는 HTTP 캐싱 헤더를 응답(respo.. 2020. 3. 25.
[Spring Boot] 4 자동설정, @SpringBootApplication 이 글은 스프링 공식문서를 보며 강의해주신 백기선 유투버님의 강의를 듣고 요약한 글입니다. Spring Boot 003 내용과 이어집니다. 3.2 XML Configuration resources/application.xml 에 Bean 을 설정해서 UserService를 등록해봅시다. main 메서드가 있는 클래스 위에 @ImportResource("application.xml")를 설정해주면, 성공적으로 bean을 찾을 수 있습니다. 4 Auto-Configuration @SpringBootApplication 은 jar 의존성에 근거해서 자동으로 스프링 application을 설정할 수 있습니다. 아래 3개를 포함하고 있습니다. @SpringBootConfiguration @EnableAutoCon.. 2020. 3. 23.
728x90