【发布时间】:2016-05-04 15:17:42
【问题描述】:
我有一个旧的 Spring xml 配置。
<jee:jndi-lookup jndi-name="ree/configuration" cache="true" id="re-properties-config" />
在 WebSphere 8 中,我在 JNDI 名称“ree/configuration”下有一个“资源环境提供者”和一个“资源环境条目”。 Referenceables 类是 java.util.Properties。
使用 xml 配置一切正常。来自 WebSphere 的“资源环境条目”映射到属性对象中。
现在我想迁移到 Spring JavaConfig。 什么是最好的解决方案?
我试试这个:
private static Properties jndiProperties() {
Properties properties = null;
JndiTemplate jndi = new JndiTemplate();
try {
properties = (Properties)jndi.lookup("ree/configuration");
LOG.info("JNDI Properties loaded: " + properties);
} catch (NamingException e) {
LOG.error("NamingException for ree/configuration", e);
}
return properties;
}
但它因 ClassCastException 而失败。 javax.naming.Reference 不能转换为 java.util.Properties
【问题讨论】:
标签: java spring websphere jndi