사용자 도구

사이트 도구


springframework:springboot

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
springframework:springboot [2018/07/18 14:00]
kwon37xi [Date/Time Format]
springframework:springboot [2018/11/28 12:52]
kwon37xi
줄 6: 줄 6:
   * [[springframework:springboot:properties|SpringBoot Properties]]   * [[springframework:springboot:properties|SpringBoot Properties]]
   * [[springframework:springboot:jpa|Spring Boot And JPA]]   * [[springframework:springboot:jpa|Spring Boot And JPA]]
 +  * [[springframework:springboot:mvc|SpringBoot and Spring MVC]]
 +  * [[springframework:springboot:json|SpringBoot and JSON]]
 +  * [[springframework:springboot:batch|SpringBoot와 SpringBatch]]
 +  * [[springframework:springboot:springboot_admin|SpringBoot Admin]]
  
 +===== @EnableAutoConfiguration =====
 +  * [[https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html|@EnableAutoConfiguration]]
 +  * 특정 Auto Configuration 방지<code java>
 +@EnableAutoConfiguration(exclude = {
 +    DataSourceAutoConfiguration.class,
 +    DataSourceTransactionManagerAutoConfiguration.class,
 +    HibernateJpaAutoConfiguration.class})
 +</code>
 +  * [[https://www.baeldung.com/spring-boot-custom-auto-configuration|A Custom Auto-Configuration with Spring Boot | Baeldung]]
 ===== Dependency Version Override ===== ===== Dependency Version Override =====
 의존 라이브러리의 버전을 다른 것으로 바꾸고자 한다면 property를 변경하면 된다. 의존 라이브러리의 버전을 다른 것으로 바꾸고자 한다면 property를 변경하면 된다.
줄 20: 줄 33:
  
  
-===== Date/Time Format ===== 
-  * [[http://www.popit.kr/rest-api-%eb%82%a0%ec%a7%9c%ec%8b%9c%ea%b0%84-%ed%91%9c%ed%98%84-%ec%a0%95%ed%95%98%ea%b8%b0/|REST API 날짜/시간 표현 정하기]] 
-  * [[http://javacan.tistory.com/478|자바캔(Java Can Do IT) :: 스프링 부트 2.0과 1.5의 Jackson JSON 날짜 타입 포맷 설정]] 
-  * [[http://lewandowski.io/2016/02/formatting-java-time-with-spring-boot-using-json/|Formatting Java Time with Spring Boot using JSON | Craftsmanship Archives]] 
-  * 1.x와 2.x 에서 동일 결과를 낼 수 있는 방식 지정할 것. 
-  * ''WRITE_DATES_AS_TIMESTAMPS'' 옵션을 변경할 경우 기존에 작동하던 ''java.util.Date''의 포맷이 변경되므로 프로젝트가 이미 운영중일 때는 건들지 말 것. 
  
 ===== DataSource ===== ===== DataSource =====
줄 38: 줄 45:
 </code> </code>
   * 위 예에서 설정값은 ''my.datasource.*''로 구성한다. [[java:database:hikaricp|HikariCP]] 등 다른 구현체를 사용할 수도 있다.   * 위 예에서 설정값은 ''my.datasource.*''로 구성한다. [[java:database:hikaricp|HikariCP]] 등 다른 구현체를 사용할 수도 있다.
 +
 +===== BootRun =====
 +==== Debug Mode ====
 +<code groovy>
 +bootRun {
 +    if (project.hasProperty("bootDebug")) {
 +        jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"]
 +    }
 +}
 +
 +// suspend=y는 JVM이 뜰 때 Remote Debugger가 접속될 때까지 기다린다.
 +// 실행 후 바로 종료하는 명령행 애플리케이션의 경우 무조건 y
 +</code>
 +
 +<code sh>
 +# -PbootDebug 프라퍼티를 지정하면 디버그 모드로 뜬다.
 +./gradlew bootRun -PbootDebug
 +</code>
 +
 +==== Application Arguments ====
 +  * [[https://www.baeldung.com/spring-boot-command-line-arguments|Command-line Arguments in Spring Boot | Baeldung]]
 +<code groovy>
 +bootRun {
 +    if (project.hasProperty('args')) {
 +        args project.args.split(',')
 +    }
 +}
 +</code>
 +
 +위와 같이 설정하고, 아래와 같은 형태로 실행한다.
 +
 +<code sh>
 +./gradlew bootRun -Pargs=param1,param2,...
 +</code>
 +
 +==== Property Override ====
 +  * [[https://stackoverflow.com/questions/36923288/how-to-run-bootrun-with-spring-profile-via-gradle-task|java - How to run bootRun with spring profile via gradle task - Stack Overflow]]
 +
 +=== Environment Variable 사용 ===
 +<code>
 +SPRING_PROFILES_ACTIVE=test gradle clean bootRun
 +
 +// on Windows
 +SET SPRING_PROFILES_ACTIVE=test
 +gradle clean bootRun
 +</code>
 +
 +
 +=== Gradle 에 System Property 그대로 계승 ===
 +<code>
 +bootRun.systemProperties = System.properties
 +</code>
 +
 +=== 새로운 bootRun Task 로 만들어버리기 ===
 +  * 새로운 ''bootRun'' 태스크를 만들고, 거기에 각종 기본 설정 추가
 +<code>
 +task bootRunDev(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
 +    group = 'Application'
 +
 +    doFirst() {
 +        main = bootJar.mainClassName
 +        classpath = sourceSets.main.runtimeClasspath
 +        systemProperty 'spring.profiles.active', 'dev'
 +    }
 +}
 +</code>
 +
 +
 +==== SpringApplicationRunListener ====
 +  * [[https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/SpringApplicationRunListener.html|SpringApplicationRunListener]]
 +  * SpringBoot 로딩중 이벤트를 받아 처리한다.
  
 ===== 참고 ===== ===== 참고 =====
springframework/springboot.txt · 마지막으로 수정됨: 2022/10/26 10:14 저자 kwon37xi