从v3迁移后,Spring 4配置出现问题(util:properties位置不再评估spEL)



我有一个正在工作的spring3应用程序,在迁移到4.1.0.RELEASE后开始出现问题。以下配置已停止工作:

<jee:jndi-lookup id="dit_properties_path" jndi-name="dit_properties_path" resource-ref="true" />
<util:properties id="systemProperties" location="classpath:system.properties" />
<util:properties id="serverProperties" location="#{dit_properties_path}"/>

迁移后,spring似乎无法解析spEL #{dit_properties_path},并显示以下错误:

[PropertiesFactoryBean] [INFO]:    Loading properties file from ServletContext resource [/#{dit_properties_path}]
[...]is java.io.FileNotFoundException: Could not open ServletContext resource [/#{dit_properties_path}]

Jndi资源的类型为java.lang.String,指向本地FS(C:\someFile.properties)。以下是tomcat对资源/服务器和上下文/的定义:

    <Environment name="dit_properties_path" value="file:C:someFile.properties"
     type="java.lang.String" override="true"/>

<ResourceLink name="dit_properties_path" 
    type="java.lang.String" 
    global="dit_properties_path" />

有人知道如何解决这个问题吗?我的应用程序中有几个属性文件,#{propertyFileId['key']}经常访问这些文件,它们必须从jndi资源路径动态加载。

更改自:

<util:properties id="serverProperties" location="#{dit_properties_path}"/>

至:

<util:properties id="serverProperties" location="${dit_properties_path}"/>

解决了问题。仍然无法理解为什么给定的表达式不能使用哈希符号。

最新更新