目前是通过
<context:property-placeholder location="classpath:global.properties" />
的方式多环境打包,global.properties 文件中主要配置了数据库密码以及URL前缀等,但是我希望在
<bean name="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="cacheSeconds" value="5" />
<property name="basenames">
<list>
<value>/WEB-INF/conf/system</value>
<value>/WEB-INF/conf/url</value>
</list>
</property>
</bean>
中的property内也能使用被 property-placeholder 的设置格式化,请问大神们,该如何处理?非常感谢
global.properties 里面格式大致有
app.name=app
app.base=http://127.0.0.1:8080/app-web/
app.static=http://127.0.0.1/app/
我希望在 /WEB-INF/conf/url 地址配置里面如下方式使用
web.index.url=${app.base}home/index.action
web.login.url=${app.base}user/login.action
web.static.url=${app.static}lib/js/
但是目前不生效,查看了org.springframework.context.support.ReloadableResourceBundleMessageSource类的resolveCode(String code, Locale locale)方法
/**
* Resolves the given message code as key in the retrieved bundle files,
* using a cached MessageFormat instance per message code.
*/
@Override
protected MessageFormat resolveCode(String code, Locale locale) {
if (this.cacheMillis < 0) {
PropertiesHolder propHolder = getMergedProperties(locale);
MessageFormat result = propHolder.getMessageFormat(code, locale);
if (result != null) {
return result;
}
}
else {
for (String basename : this.basenames) {
List<String> filenames = calculateAllFilenames(basename, locale);
for (String filename : filenames) {
PropertiesHolder propHolder = getProperties(filename);
MessageFormat result = propHolder.getMessageFormat(code, locale);
if (result != null) {
// 这里没有格式化
return result;
}
}
}
}
return null;
}
这个是不是无法实现,或者我希望在Java代码中,如何取到的实体,手动处理?