我正在使用带有 Spring STS 3.1.0 的 Eclipse Juno。我在同一个工作区中有 2 个 mvc 项目。其中一个项目可以发送和接收 jms 消息。它使用 Spring JmsMessagListener bean 来接收消息。bean 映射到具有 onMessage 方法的侦听器类。当我在 VMWare tc 服务器上运行没有 jms 的项目时,我每 5 秒在控制台中收到以下消息:
警告:org.springframework.jms.listener.DefaultMessageListenerContainer - 无法刷新目标“mht.alert.queue”的 JMS 连接 - 5000 毫秒后重试。原因:无法连接到代理 URL:tcp://localhost:61616。原因:java.net.ConnectException:连接超时:连接
该项目似乎正在尝试连接到我没有运行的 activemq 代理,因为我没有运行内置 jms 的项目。我不明白为什么会发生这种情况。我已经包含了这两个项目的 web.xml 文件。希望有人能给我一个关于为什么会发生这种情况的线索。这不是什么大问题,因为我可以忽略这些消息或让代理让它们保持沉默,但最好妥善处理它。
提前致谢
这是没有 jms 的项目的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns
/javaee/web-app_3_0.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
<listenerclass>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
这是内置 jms 的项目的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml,
/WEB-INF/spring/jms-config.xml,
/WEB-INF/spring/security-config.xml,
/WEB-INF/spring/datasource-tx.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--<start id="filter_security" /> -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<!--<end id="filter_security" />-->
<!--<start id="filter_mapping_security" /> -->
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--<end id="filter_mapping_security" />-->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- This servlet is mapped to all requests at the root level -->
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
这是我的root-context.xml的内容,不是spring-security.xml被注释掉了
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<!-- Import the datasource-tx.xml file to configure the StudentDao service and make
it visible to the entire application
-->
<import resource="classpath:datasource-tx.xml" />
<!-- <import resource="spring-security.xml" /> -->
</beans>