Using Spring, I want to read a variable inside the context of Webspehere.
Read a Environment Variable in Java with Websphere
To define the data.... inside web.xml
<env-entry>
<env-entry-name>varName</env-entry-name>
<env-entry-value>56</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
To see with java
Context envEntryContext = (Context) new InitialContext().lookup("java:comp/env");
String mydata = (String)envEntryContext.lookup(“varName”);
But I want take the data in my common.xml like
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/context/servweb.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders">
<value>true</value>
</property>
</bean>
maybe with something like that
<constructor-arg>
<jee:jndi-lookup jndi-name="java:comp/env" default-value="data" />
</constructor-arg>
but with context for do the same that
Context envEntryContext = (Context) new InitialContext().lookup("java:comp/env");
String mydata = (String)envEntryContext.lookup(“varName”);
maybe something like that:
<constructor-arg>
<jee:jndi-lookup jndi-name="java:comp/env">
<jee:environment>
varName=default
</jee:environment>
</jee:jndi-lookup>
Anybody knows the correct way?
Thanks in Advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…