코딩 관련/Spring 관련
[Spring Boot] -Dspring 사용, spring boot 환경설정
메리짱123
2021. 8. 18. 14:55
반응형
jar 파일 실행시 spring의 환경설정을 변경하게 해줌.
java 실행 명령어 입력 시
application.properties의 내용 중 profiles > active의 값을 변경할 경우
옵션을 다음과 같이 준다.
-Dspring.profiles.active = local
예시
//active 할 profile 설정
java -jar -Dspring.profiles.active=dev ./test.jar
//springApplication의 프로퍼티설정파일의 이름을 변경
java -jar myproject.jar --spring.config.name=myproject
//프로퍼티설정파일의 경로를 명시하여 특정 파일을 참조하게 한다.
java -jar -Dspring.config.location=classpath:/application.properties,/home/ec2-user/app/application-oauth.properties
//classpath가 붙으면 jar 안에 있는 resources 디렉토리를 기준으로 경로가 생성됨.
//classpath가 없는 경우는 외부에 파일이 있어서 절대경로를 명시한 경우임.
Dspring 및 spring 환경설정 관련하여 참조할 수 있는 페이지
Spring Boot Features
Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest
docs.spring.io
[Spring Boot] 외부에서 설정 주입하기 - Increment
4.2. 외부에서 설정 주입하기 Spring boot 애플리케이션의 설정 값을 외부에서 전달하는 방법을 다룹니다. 기준 버전은 2.2x입니다. Spring Boot는 동일한 애플리케이션 코드를 다른 환경에서 작업할 수
www.latera.kr
반응형