[英]How I can configure properties file right?
I have maven project with several modules 我有几个模块的Maven项目
this is part of database-config.xml in office-core module: 这是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>
I have application.properties files on several places: 我在几个地方都有application.properties文件:
c:\\projects\\office\\app\\office-core\\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 \\ office-core \\ src \\ main \\ profiles \\ application.properties
c:\\projects\\office\\app\\application.properties c:\\ projects \\ office \\ app \\ application.properties
In my opinion with this config in database-config.xml I should can use the properties file in my database-config.xml but I cant... Any help ? 我认为使用database-config.xml中的此配置,我应该可以使用我的database-config.xml中的属性文件,但是我不能...有帮助吗?
You should put the application.properties
file to src/main/resources
directory to have it effectively on classpath. 您应该将
application.properties
文件放在src/main/resources
目录中,以使其有效地位于类路径上。 Then it should work. 然后它应该工作。
I think it will not work because those paths are not part of your classpath. 我认为它将不起作用,因为这些路径不是您的类路径的一部分。 I suggest you to have some default configuration and to have configuration override per module, something like that:
我建议您具有一些默认配置,并让每个模块具有配置覆盖,如下所示:
<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.