我在我的類路徑中的jndi.properties文件中定義了jms連接設置,該文件用於在本地開發環境中連接到ActiveMQ。我想將這個文件重命名爲「activemq.jndi.properties」,因爲我打算給WebsphereMQ另外設置jms連接設置(比如說webshperemq.jndi.properties)。不過,在我的applicationContext.xml中查看activemq.jndi.properties時,我目前還沒有成功告訴spring。根據配置文件在彈簧應用程序上下文中加載不同的jndi.properties文件
這裏是我的applicationContext.xml的片段,其適用於jndi.properties
<!-- Define how to connect to the Message Queueing system -->
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jms.connectionFactory}" />
<property name="resourceRef" value="true" />
</bean>
<bean id="defaultDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jms.topic}" />
<property name="resourceRef" value="true" />
</bean>
<!-- Define a connection template that links to the factory -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestination" ref="defaultDestination" />
<property name="receiveTimeout" value="6000" />
</bean>
兩個$ {jms.connectionFactory}和$ {} jms.topic正在從行家過濾。任何關於需要在我的applicationContext.xml中進行更改以使其從activemq.jndi.properties加載的輸入將非常感激。
謝謝!
嗨jddsantaella,感謝您的輸入,但是元素不是行家元素內有效,所以你的建議上面就不會工作。基本上,如果我將jndi.properties重命名爲activemq.jndi.properties,如何告訴spring(如果可能的話)「查看」activemq.jndi.properties而不是jndi.properties(這是Spring將加載的默認值)? –
資源定義在配置文件內有效。我已經更新了我的答案,向您展示了整個結構 – jddsantaella