1

我正在使用 glassfish 3.1、spring 3.2 和 jdk 1.7。

我在 Glassfish 中配置了两个自定义 JNDI 资源。一个称为“配置”,另一个称为“映射”。但是当我在代码中引用其中一个时,它实际上具有两个和所有系统属性(catalina.base 等)的属性。我只想要一套,不是全部3套。

我已经设置好了,所以我得到了 spring 上下文文件中的属性:

<jee:jndi-lookup id="mappingsJndi" jndi-name="mappings" resource-ref="true" />
<bean id="propertyMappings" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="propertiesArray">
            <list>
                <ref bean="mappingsJndi"/>
            </list>
        </property>
    </bean>

我在 servlet 中引用它。它是这样注入的:

@Autowired
Properties[] propertyMappings;

注入有效,但它包含 3 个属性对象而不是一个。有没有办法解决?

4

1 回答 1

3

看来我想通了。而不是像这样引用 propertyMappings bean:

@Autowired
Properties[] propertyMappings;

我只是直接引用 JNDI 查找:

@Autowired
Properties mappingsJndi;
于 2013-01-04T19:23:00.703 回答