back-end/SPRING
SpringBoot - tomcat(spring profile 호출 방법)
현창이
2021. 2. 25. 17:55
1. 먼저 스프링 부트 application.yml에 아래와 같이 profiles를 정의한다.
- properties 파일인 경우 spring.profiles.active=prod 설정
2. tomcat/bin 디렉토리에서 setenv.sh 파일 생성 후 아래와 같이 입력 후 저장하고 실행
- setenv.sh : tomcat 구동시 실행 환경 설정 파일, JAVA_OPTS등 환경 설정이 가능합니다. 또한 이파일은 기본으로 제공되는 파일이 아니라서 직접 쉘 파일을 생성 및 작성을 해야합니다.
- 효과 : 빌드시 개발, 테스트, 운영 나눠서 빌드할 필요없이 같이 가능. 원하는 환경으로 실행
- 참고
docs.spring.io/spring-boot/docs/1.2.0.M1/reference/html/boot-features-profiles.html
22. Profiles
Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments. Any @Component or @Configuration can be marked with @Profile to limit when it is loaded: In the normal Spring way, you ca
docs.spring.io