我现在有3个属性文件:
application.properties春天引导属性文件外化
[email protected]@
application-develoment.properties
#DB properties:
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/mydb
db.username=user
db.password=pswd
#Data source management:
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=true
hibernate.current_session_context_class=thread
application-production.properties
#DB properties:
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/myproddb
db.username=admin
db.password=admin
#Data source management:
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=false
hibernate.current_session_context_class=thread
我有我的Maven的轮廓在我的pom.xml
<profiles>
<profile>
<id>development</id>
<properties>
<activatedProperties>development</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>production</id>
<properties>
<activatedProperties>production</activatedProperties>
</properties>
</profile>
</profiles>
如下,并设置我的DataSourceConfig的:annotaion @PropertySource(值= “类路径:application.properties”)
当我用开发或生产配置文件进行编译时,一切正常,但现在我想将属性文件外化到我的Tomcat服务器的/ conf/localhost目录,有关如何执行此操作的任何想法?
只需将应用程序 - *。properties文件放置在部署了.jar的位置。 –