【发布时间】:2014-02-03 19:06:41
【问题描述】:
我在实现的一个 SystemEventListener 中遇到了问题。我正在使用注释 @Value 从属性文件中注入一个值。问题是注释 @Value 在应用程序的其他部分(例如 @Controller)中运行良好,但在此 SystemEventListener 中运行不佳。它也适用于 tomcat,但不适用于 Websphere 8.5。
你知道它可能是什么吗?
实施
public class PreRenderViewListener implements SystemEventListener {
@Value("${path}/fileName.properties")
private String filePath;
faces-config.xml
<system-event-listener>
<system-event-listener-class>com.package.PreRenderViewListener</system-event-listener-class>
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
解析器是一个扩展类PropertyPlaceholderConfigurer的bean,运行良好。
<bean id="uxMasterConfigBean" class="com.csc.cscip.ux.common.util.UXPropertiesConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:/resources/master/ux.default.configuration.properties</value>
<value>${ux.master.configuration.file.path}</value>
</list>
</property>
</bean>
此配置在Tomcat中运行良好,所以我认为这不是代码问题,可能是与Websphere 8.5相关的问题。我一直在互联网上寻找这个问题,但我没有找到类似的东西。
感谢您的帮助!
【问题讨论】:
-
我会很惊讶它会起作用,基本上,WebSphere 中的行为是我期望发生的。
PreRenderViewListener是 JSF(面孔)托管 bean,而不是 Spring 托管 bean,因此@Value不应该工作。
标签: java spring jakarta-ee websphere websphere-8