在PropertyPlaceholderConfigurer实例中使用< jee:jndi-lookup字符串 [英] using a <jee:jndi-lookup string inside an instance of PropertyPlaceholderConfigurer

查看:106
本文介绍了在PropertyPlaceholderConfigurer实例中使用< jee:jndi-lookup字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:Windows Server 2003,Spring 3.0,Tomcat 6

Environment: Windows server 2003, Spring 3.0, Tomcat 6

如何在PropertyPlaceholderConfigurer中引用JNDI属性?

How can I reference a JNDI property inside a PropertyPlaceholderConfigurer?

具体来说,我正在使用JNDI查找一个java.lang.String,它表示一个到 我的网络应用所需的属性文件

Specifically, I'm using JNDI to look up a java.lang.String that represents a path to a property file needed by my webapp

<jee:jndi-lookup id="mypropsfile1" jndi-name="myPropsFile1" resource-ref="true"/>
<jee:jndi-lookup id="mypropsfile2" jndi-name="myPropsFile2" resource-ref="true"/>

<bean id="propertyConfigurer" 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="ignoreUnresolvablePlaceholders" value="true"/>
  <property name="locations">
    <array>
        <value>how to use mypropsfile1 here ??</value>
        <value>how to use mypropsfile2 here ??</value>
    </array>
  </property>
</bean>

我的"jee:jndi-lookup"正在运行AFAIK.我的问题似乎是如何引用JNDI资源 标签对内

My "jee:jndi-lookup"s are working AFAIK. My problem seems to be how to reference JNDI resources inside the tag pair

提前谢谢! 标记

推荐答案

不完全是单个JNDI属性,而是使用通过JNDI获取的Properties引用:

Not exactly for a single JNDI property, this is using a Properties reference instead, obtained through JNDI:

<!-- Lookup Properties reference through JNDI -->
<jee:jndi-lookup id="config-properties" jndi-name="resources/resource-name" resource-ref="true"/>

<bean id="propertyConfigurer" 
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" depends-on="config-properties">
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <!-- Once the reference is obtained from JNDI, it can be used like any other reference -->
    <property name="properties" ref="config-properties"></property>
</bean>

这篇关于在PropertyPlaceholderConfigurer实例中使用&lt; jee:jndi-lookup字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆