Spring 的 PropertyPlaceholderConfigurer 与 jar 文件中的属性 [英] Spring's PropertyPlaceholderConfigurer with property in a jar file

查看:65
本文介绍了Spring 的 PropertyPlaceholderConfigurer 与 jar 文件中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个属性文件需要参考.下面我可以参考classpath中的两个.

I have multiple property files I need to refer to. Below I can refer to two that are on the classpath.

如何引用 jar 文件中的属性文件?

How do I refer to a property file with in a jar file ?

  <bean  id="placeholderConfig" name="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
  <list>
    <value>classpath:config/my_test.properties</value>
    <value>classpath:config/some_other.properties</value>
  </list>
</property>

推荐答案

如果 JAR 在类路径中,那么您可以像引用任何其他资源一样引用其中的属性文件.只需在 JAR 文件中指定属性文件的位置即可.

If the JAR is in the classpath, then you can reference the properties file inside just like any other resource. Just specify the location of the properties file within the JAR file.

这篇关于Spring 的 PropertyPlaceholderConfigurer 与 jar 文件中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆