반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- RabbitMQ
- WebLogic
- spring cloud
- argo cd
- Docker Compose
- Spring Open Feign
- ChannelPipeline
- coalesce
- netflix oss
- Redis Sentinel
- Hibernate
- Selenium
- spring boot redis
- Netty
- QueryDSL
- docker compose mysql
- weblogic 10
- JPA
- cassandra
- vue.js
- KAFKA
- redis
- MySQL
- mybatis
- Airflow
- grafana
- spring boot
- docker-compose
- docker
- jmeter
Archives
- Today
- Total
IT.FARMER
Spring devtools restart 파일 감지 본문
반응형
스프링부트 개발자툴 활용하기,
개발시 resource 성격의 파일을 리로드할때, 혹은 변경된 클레스만 핫스와핑 하여 사용시
- spring devtools 모듈을 설정 하여 사용한다.
- spring.devtools.restart.enabled 설정으로 restart 제어 .
재시작 비활성화 (false 시)
.application.preperties
- 클레스 로더 초기화 하여 핫스와핑은 되지만 파일 감지는 없음 (제한적)
.java main method에 System preperties
- 재시작 지원을 완벽히 비활성화 할때, 예를 들면 특정 라이브러리에서만 비활성화시.
Debug Mode 로 실행해야 동작 한다.
(spring boot version 2.0.3.RELEASE)
maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!--restart 를 원하지 않을 경우 false -->
</dependency>
gradle
compile group: 'org.springframework.boot', name: 'spring-boot-devtools'
application.yml(application.properties)
spring:
mvc:
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
devtools:
livereload:
enabled: true # livereload 사용시 활성화
restart:
enabled: false #운영 에서는 제거.
java main method 실행
public static void main(String[] args) {
// hot deploy 후 자동 리스타트 하지 않도록 한다, Run Application 프로퍼티에서 false로 설정.
// 완전한 재시작 없음 메인메소드에서 프로퍼티 삽입
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication app = new SpringApplication(WebApplication.class);
app.setBannerMode(Banner.Mode.CONSOLE);
app.run(args);
}
인텔리 J에서 사용시 해당 IDE 내용을 활성화 할것 ( 혹은 ctrl+f9 을 누르면 클레스 리로딩 물어봄)
- Enable "Build project automatically" from Settings->Build, Execution, Deployment->Compiler
- Go to Registry(Ctrl+A, type "Registry") and enable compiler.automake.allow.when.app.running and ide.windowSystem.autoShowProcessPopup
결론
devtools이용시 이렇게 해도 저렇게 해도 안될때가 많은데 , 테스트해본결과 IDE에서는 debug 모드에서만 동작되며
잦은 restart는 하지 않기 위해 false로 사용한다. (프로퍼티는 yml / 코드않에서 / 실행시 옵션중 선택하여 한곳에서만 해주면 된다. 굳이 세군데 다변경해줄 필요 없음.)
반응형
'Spring > Spring Boot' 카테고리의 다른 글
Spring boot admin (0) | 2020.06.22 |
---|---|
Spring Cloud Config (0) | 2020.06.22 |
Springboot jpa & Hibernate Naming Strategy(네이밍 전략) (1) | 2018.08.31 |
Spring boot Swagger (0) | 2017.08.31 |
Spring Boot mobile project 에 tiles 적용 (0) | 2017.02.03 |