[英]How can I configure a .properties file to dynamically pull usernames and passwords from a MariaDB database?
[英]How I can configure properties file right?
我有几个模块的Maven项目
这是office-core模块中database-config.xml的一部分:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:application.properties</value>
</list>
</property>
</bean>
我在几个地方都有application.properties文件:
c:\\ projects \\ office \\ app \\ office-core \\ application.properties
c:\\ projects \\ office \\ app \\ office-core \\ src \\ main \\ profiles \\ application.properties
c:\\ projects \\ office \\ app \\ application.properties
我认为使用database-config.xml中的此配置,我应该可以使用我的database-config.xml中的属性文件,但是我不能...有帮助吗?
您应该将application.properties
文件放在src/main/resources
目录中,以使其有效地位于类路径上。 然后它应该工作。
我认为它将不起作用,因为这些路径不是您的类路径的一部分。 我建议您具有一些默认配置,并让每个模块具有配置覆盖,如下所示:
<bean id="overrideConfigurer" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="location" value="file:/SomeFolderInFileSystem/conf.properties"/>
<property name="ignoreResourceNotFound" value="true"/>
</bean>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.