每天進步一點點,fighting...
Profile是Spring用來針對不同的環境對不同的配置提供支持的,全局Profile配置使用,application-{profile}.properties(如application-prod.properties)
通過在application.properties中設置spring.profiles.active = prod來指定活動的Profile
你可以有
application.properties
application-dev.properties
application-pro.properties
然後在application.properties中,設置
spring.profiles.active=dev
在項目工程裏面,可能會把項目分成不同的模塊,比如
common
job
model
portal等
這樣一來,可以在總工程下有一個pom.xml來指定 profile
<!--統一配置--> <profiles> <profile> <id>dev</id> <properties> <evn.active>dev</evn.active> <!--由於bootstrap先啓動,不能放在application裏面--> </properties> </profile> <profile> <id>test</id> <properties> <evn.active>test</evn.active> <!--由於bootstrap先啓動,不能放在application裏面--> </properties> </profile> <profile> <id>pro</id> <properties> <evn.active>pro</evn.active> <!--由於bootstrap先啓動,不能放在application裏面--> </properties> </profile> <profile> <id>devtest</id> <properties> <evn.active>devtest</evn.active> <!--由於bootstrap先啓動,不能放在application裏面--> </properties> </profile> </profiles>
這樣一來,可以在idea右側的Maven Project中選擇profile
需要什麼環境,就勾選哪個就行了