我正在爲websphere 7.0開發Web應用程序。它是XML基於彈簧3.1應用程序。在我的應用程序中,我使用許多配置屬性文件但在生產中,我們無法訪問websphere服務器上的文件系統,因此我們無法訪問spring或屬性文件或web.xml。因此,我們需要從Websphere管理控制檯中的配置文件中覆蓋屬性。但是,我們也需要通過編程訪問解決管理員重寫的某些屬性的值。重寫spring 3.1 websphere console中的屬性
我發現上下文:property-placeholder解析web.xml中的上下文參數和entry-env,並覆蓋文件中的屬性,因爲它應該在我的應用程序中,但我不知道如何以編程方式獲取屬性從上下文:屬性佔位符(這是新的PropertySourcesPlaceholderConfigurer)。 在我的情況下,我無法得到util:屬性被上下文參數或entry-env值覆蓋。 As和PropertyPlaceholderConfigurer。
另外,我無法從websphere管理控制檯編輯上下文參數。我沒有找到這個功能,谷歌也沒有給出答案。在控制檯中,我只能編輯servlet初始化參數或entry-env值。
我的情況: web.xml中:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/webappconf.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/springServlet</url-pattern>
</servlet-mapping>
<env-entry>
<env-entry-name>AA.AA</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Override AA.AA</env-entry-value>
</env-entry>
webappconf.xml
any properties resolver definition
<bean id="springService" class="ru.test.krp.SpringService">
<property name="a" value="${AA.AA}" />
<property name="b" value="${BB.BB}" />
<property name="c" value="${CC.CC}" />
<property name="config" ref="any refrence to properties for access from code"/>
</bean>
<bean id="springServlet" class="ru.test.krp.SpringServlet">
<property name="springService" ref="springService"></property>
</bean>
SpringService.java
public class SpringService {
private String a;
private String b;
private String c;
private Properties config;
// getter/setter pairs
我會感謝任何幫助或想法。