将spring框架迁移到4.2.8(从版本4.1.6开始)后,我无法通过自定义PropertyPlaceholder加载配置。
<bean id="customPlaceHolderConfigurer" class="xxx.CustomPlaceHolderConfigurer">
<property name="order" value="#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE + 10}" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
<jaxws:client id="wsBusinessService" address="${pf:WS_URL}/soap/ws" serviceClass="xxx.WSBusinessService" />
和CustomPlaceholder
public class CustomPlaceHolderConfigurer extends PropertyPlaceholderConfigurer {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomPlaceHolderConfigurer.class);
@Override
protected String resolvePlaceholder(final String pPlaceholder, final Properties pProps) {
String value = null;
if (pPlaceholder != null) {
if (CIStringUtils.startsWith(pPlaceholder, "pf")) {
String propertyKey = StringUtils.substring(pPlaceholder, 3);
if (propertyKey.contains(":")) {
String defaultValue = StringUtils.substringAfter(propertyKey, ":");
String newKey = StringUtils.substringBefore(propertyKey, ":");
value = Plateforme.getProperty(newKey, defaultValue);
} else {
value = Plateforme.getProperty(propertyKey);
}
}
}
LOGGER.debug("placeholder '{}' resolved to '{}'", pPlaceholder, value);
return value;
}
}
当我启动应用程序时,我得到以下日志:
2016-12-13T15:52:12,448 [localhost-startStop-2] DEBUG CustomPlaceHolderConfigurer - placeholder 'pf:WS_URL' resolved to 'services.com'
但jaxws抛出异常,因为该属性未被替换:«无法找到地址的管道发起人:$ {pf:WS_URL} / soap / ws和transport:http://schemas.xmlsoap.org/soap/http»
我知道配置的加载顺序已更改为弹簧4.2.x,但即使更改顺序也无法操作。 (https://github.com/spring-projects/spring-framework/wiki/Migrating-to-Spring-Framework-4.x)
Spring Framework 4.2带来了重要的微调 配置类处理。可能存在微妙的差异 登记顺序与4.1相比;但是,这些都被考虑了 以前没有明确定义的行为修复。如果你是 依赖于特定的订单,例如请按名称覆盖豆类 考虑使用4.2的新设施,特别是@Order注释 在配置类上。
我试过了:
#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE + 10}
#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE}
-1
1
有没有人遇到过这个问题?
由于