전체 글
-
[11] Spring Web MVC: HttpMessageConvertersSpring/Spring boot 2020. 6. 17. 08:51
[HttpMessageConverters] HttpMessageConverters에 대한 reference site는 다음과 같습니다. docs.spring.io/spring/docs/5.0.7.RELEASE/spring-framework-reference/web.html#mv%20c-config-message-converters HttpMessageConverters는 Spring framework에서 제공하는 interface이고 Spring MVC의 일부분입니다. Http request body를 객체로 변환하거나, 객체를 Http response body로 변환할 때 사용합니다. (HTTP reqeust, response 참고) HttpMessageConverters를 사용하기 위한 annotat..
-
[10] Spring Web MVC: IntroductionSpring/Spring boot 2020. 6. 15. 13:18
Spring boot MVC reference site : https://docs.spring.io/spring/docs/5.0.7.RELEASE/spring-framework-reference/web.html#spring-web Web on Servlet Stack This part of the reference documentation covers support for Servlet stack, WebSocket messaging that includes raw WebSocket interactions, WebSocket emulation via SockJS, and pub-sub messaging via STOMP as a sub-protocol over WebSocket. 4.1. Introduc..
-
[09] TestSpring/Spring boot 2020. 6. 10. 19:18
[Test를 하는 이유] 개발에 관심이 있는 분들은 TDD(Test Driven Development)를 들어보셨을 겁니다. TDD는 우선 code에 대한 Test를 작성 후 Test를 수행함에 따라 발생한 오류의 수정과 중복된 code를 제거하는 refactoring을 진행해 유지보수가 용이한 simple한 code를 얻기 위한 개발 방법입니다. 완벽한 TDD를 도입하지 않더라도 Test code를 추가하면 유지보수에 따른 오류를 미연에 방지할 수 있으며 개발자는 자신의 code에 대한 확신을 가질 수 있게 됩니다. Spring boot는 test를 위한 의존성 하나만 추가하면 test에 필요한 여러 도구들을 사용할 수 있게 되어 매우 편리합니다. [Test관련 의존성 추가] Test를 위해 proje..
-
[08] Spring boot loggingSpring/Spring boot 2020. 6. 5. 08:55
[Logging facade] Commons Logging, SLF4j(Simple Logging Facade for Java). logger API를 추상화 한 interface들입니다. framework 개발자들이 주로 사용합니다. logging facade를 사용하면 logger를 변경할 수 있습니다. Spring boot 개발 당시 logging facade로 Commons Logging을 사용했습니다. 하지만 Commons Logging은 여러 가지 문제점을 내포합니다. Commons Logging의 문제점을 해결하기 위해 새롭게 등장한 logging facade가 SLF4j이며 이를 사용하기 위해 spring boot 1.x대에서는 pom.xml에서 Common Logging관련 의존성을 ex..
-
[07] ProfileSpring/Spring boot 2020. 6. 3. 21:27
profile을 사용하면 적용된 profile에 따라 bean의 등록을 달리하거나 특정 logic을 실행할 수 있도록 하여 환경에 따라 application을 유연하게 실행할 수 있습니다. (profile에 대한 자세한 예) profile을 사용하는 간단한 예제를 살펴보도록 합시다. 먼저 서로다른 profile을 적용할 bean 설정 file을 두개 준비합니다. 각각의 bean 설정 file 내용은 다음과 같습니다. @Profile("base")//① @Configuration//② public class BaseConfiguration { @Bean//③ public String printConfiguration() { return "Base Configuration"; } } ① @Profile an..
-
[06] 외부 설정 file (Property)Spring/Spring boot 2020. 6. 1. 11:52
[외부 설정의 file 종류와 우선순위] 외부 설정 file은 application에서 사용하는 여러 가지 properties를 담아놓은 file로 application 내부 또는 외부에 위치할 수 있습니다. 외부 설정 file은 다음과 같은 것들이 있습니다. properties (application.properties) YAML 환경변수 (environment variable) Command line arguments Properties는 여러 군데 산재할 수 있으며 각각의 다른 외부 설정에 동일한 property key가 존재할 경우 우선순위에 따라 property에 해당되는 value를 선택하게 됩니다. property의 우선순위는 다음과 같습니다. home directory에 있는 spring-..
-
[05] Spring ApplicationSpring/Spring boot 2020. 5. 28. 08:53
[Spring boot log에 debug log 출력하기] Ctrl + Shift + A로 검색창을 열어 edit configurations 라고 입력 후 enter를 누르면 Run/Debug Configurations 메뉴가 열립니다. VM option 또는 Program arguments를 설정해서 Spring boot 실행창에 debug log를 찍을 수 있습니다. 각각의 설정할 값은 다음과 같습니다. Debug log 내용에는 각각의 자동설정이 포함 또는 제외된 원인이 포함됩니다. VM option : -Ddebug program argument : --debug [FailureAnalyzer] Application error 발생 시 message를 보기 좋게 출력해주는 기능입니다. Sprin..
-
[04] 독립으로 실행가능한 JAR fileSpring/Spring boot 2020. 5. 26. 08:57
Spring boot project를 build하여 생성된 JAR file은 독립적으로 실행할 수 있습니다. application을 배포하거나 docker image로 만들 때는 JAR package로 packaging된 JAR file을 실행하는 것이 유용합니다. [JAR packaging과 실행 방법] build plugin을 사용하여 build 시 JAR packaging을 진행 합니다. build plugin 중 하나인 maven을 통해 packaging하고 실행하는 방법은 다음과 같습니다. mvn clean package 명령으로 target 아래 있는 모든 것을 삭제합니다. mvn package -DskipTests 명령으로 packaging을 진행합니다. (-DskipTests option으..