1. 程式人生 > >mq和spring結合使用,導致每次啟動伺服器都會卡在applicationContext-mq.xml那

mq和spring結合使用,導致每次啟動伺服器都會卡在applicationContext-mq.xml那

使用mq後,每次都會停在

10:26:18,457  INFO ContextLoader:285 - Root WebApplicationContext: initialization started
10:26:18,590  INFO XmlWebApplicationContext:510 - Refreshing Root WebApplicationContext: startup date [Tue Mar 06 10:26:18 CST 2018]; root of context hierarchy
10:26:18,649  INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext.xml]
10:26:18,996  INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext-dataSource.xml]
10:26:19,254  INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext-webService.xml]
10:26:19,396  INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext-quartz.xml]
10:26:19,414  INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext-mq.xml]那

配置檔案為:

因為之前沒有spring裡面沒有amq,所以每次啟動的時候都會去線上查詢,所以導致會很卡

http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd 

解決方法:

    配置spring的原生bean

    將

<!-- ActiveMQ 連線工廠 -->
    <amq:connectionFactory id="amqConnectionFactory"
    brokerURL="tcp://localhost:61616" userName="admin" password="admin"  />

改為:

    <bean id="amqConnectionFactory" 
    	class="org.apache.activemq.ActiveMQConnectionFactory">
    	<property name="brokerURL" value="tcp://localhost:61616"></property>
    	<property name="userName" value="admin"></property>
    	<property name="password" value="admin"></property>
    </bean>