![](/img/trans.png)
[英]SpringBoot: external application.properties not found in deploying war
[英]Springboot war project with tomcat and external application properties?
我们如何提供在外部tomcat上运行的war项目的外部application.properties,datasource.properties文件? 有什么方法可以将这些文件路径作为Tomcat参数的vm参数提供。 如果使用上述配置,是否可以从这些文件中获取值作为@Value注释?
有一个PropertySourcesPlaceholderConfigurer
<bean name="propertySourcesPlaceholderConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="location" value="file:${conf.dir}/app.properties" />
</bean>
您可以在conf.dir
通过-Dconf.dir = yourconfigFilePath这样的JVM参数传递它
并使用如下
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<property name="driverClassName" value="${dataSource.driverClassName}" />
<property name="url" value="${dataSource.url}" />
...
档案app.properties
dataSource.driverClassName=org.apache.derby.jdbc.ClientDriver
dataSource.url=jdbc:derby://localhost:1527/dbpath
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.