스프링 멀티 파일 구성 :
1. 속성 파일
2. YAML 파일
1. 속성 파일
Spring Boot에서 여러 환경에서 구성된 파일 이름은 응용 프로그램-{프로파일}을 충족해야합니다.
{profile}이 아래와 같이 환경 식별자에 해당하는 속성 형식.
• Application-Dev. Properties : 개발 환경.
• Application-Test.properties : 테스트 환경.
• Application-Prod.properties : 생산 환경.
어떤 구성 파일이로드 될지에 대해서는 앱 on.properties 파일에 전달되어야합니다.
Spring.profiles.Active 속성이 설정되어 있으며 그 값은 구성 파일의 {profile} 값에 해당합니다. 좋다
spring.profiles.active = test는 application-test.properties 구성을로드합니다
파일 내용.
2. YAML 파일
서버 : 포트 : 8080 # 기본 프로파일은 Dev입니다. 다른 환경은 다음과 같은 시작 매개 변수를 지정하여 다른 프로파일을 사용합니다. # 테스트 환경 : java -jar xxx.jar ---spring.profiles.active = java -jar xxx.jar ---sprofiles.active = prod spring : profiles : active # dev the distune venifice, histing sunguish, histing be indination "-a Disting Line" 구성 스프링 : 프로파일 : Dev DataSource : URL : jdbc : mysql : //192.168.0.152 : 3306/aylson? useUnicode = true & charac jdbc : mysql : //192.168.0.152 : 13306/aylson? useUnicode = true & characterencoding = utf-8 & usessl = false ---# 생산 환경 구성 스프링 : 프로포드 데이터 소스 : URL : URL : URL : jdbc : mysql : //192.168.0.152 : 23306/aylson? useUnicode = true & characterencoding = utf-8 & usessl = false
사용 방법 :
다음과 같은 시작 매개 변수를 지정하여 다른 프로파일을 사용하십시오.
테스트 환경 : java -jar xxx.jar spring.profiles.active = test
생산 환경 : java -jar xxx.jar spring.profiles.active = prod
위의 기사는 스프링 부팅을 기반으로 다른 구성 메소드를 사용합니다. 이 기사는 내가 당신과 공유하는 모든 내용입니다. 나는 그것이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.