2012-05-29 2 views
0

로컬 개발 환경에서 ActiveMQ에 연결하는 데 사용한 클래스 경로의 jndi.properties 파일에 정의 된 jms 연결 설정이 있습니다. 이 파일의 이름을 "activemq.jndi.properties"로 바꾸려면 WebsphereMQ (webshperemq.jndi.properties)에 다른 jms 연결 설정을 지정하려고합니다. 그러나 나는 지금까지 my applicationContext.xml에서 봄에 activemq.jndi.properties를 볼 때 아무런 성과가 없다. 여기 프로필에 따라 스프링 응용 프로그램 컨텍스트에서 다른 jndi.properties 파일로드

은 jndi.properties 모두 $ {jms.connectionFactory}와 $는 {jms.topic} 받는다는에서 필터링되는
<!-- 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> 

작동 내 applicationContext.xml의 조각입니다. activeMq.jndi.properties에서로드 할 수 있도록 내 applicationContext.xml에서 변경해야 할 사항에 대한 모든 입력은 많은 도움이됩니다.

감사합니다.

답변

1

음, Maven 리소스를 구성해야하므로 프로필에 따라 다른 구성 파일 중 하나를 사용하십시오. 대신 Spring 구성 파일의 내용을 변경하십시오. 예를 들어

:

<profiles> 
    <profile> 
     <id>local</id> 
     <build> 
      <resources> 
       <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        <includes> 
         <include>jndi.properties</exclude> 
        </excludes> 
       </resource> 
      </resources> 
     </build> 
    </profile> 
    <profile> 
     <id>webshpere</id> 
     <build> 
      <resources> 
       <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        <includes> 
         <include>webshperemq.jndi.properties</exclude> 
        </excludes> 
       </resource> 
      </resources> 
     </build> 
    </profile> 
</profiles> 
+0

안녕 jddsantaella는 귀하의 의견 주셔서 감사합니다, 그러나 요소 받는다는에서 요소 내부 유효하지 않습니다, 그래서 당신의 제안은 이상 근무하지 않을 것입니다. 기본적으로 jndi.properties의 이름을 activemq.jndi.properties로 변경하면 jndi.properties (Spring이로드 할 기본값)보다는 activemq.jndi.properties를 "보"도록 Spring을 알려줄 수 있습니까? –

+0

자원 정의는 프로파일 내에서 유효합니다. 내 대답을 업데이트하여 전체 구조를 보여주었습니다. – jddsantaella