总是报错无法找到 org.springframework.jms.connection.SingleConnectionFactory

来源:4-7 5.6 spring jms演示_1

Alan_scut

2017-10-03 23:43

producer.xml配置部分:

<context:annotation-config/>

    <!-- ActiveMQ为我们提供的ConnectionFactory -->

    <bean id="targetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">

    <property name="brokerURL" value="tcp://localhost:61616"/>

    </bean> 

    <!-- spring jms 为我们提供连接池 -->  

<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">

<property name="targetConnectionFactory" ref="targetConnectionFactory"/>

</bean>

每次一运行就报如下错误:

Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jms.connection.SingleConnectionFactory] for bean with name 'connectionFactory' defined in class path resource [producer.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jms.connection.SingleConnectionFactory

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1377)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:608)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1476)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:999)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:739)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

at com.imooc.jms.producer.AppProducer.main(AppProducer.java:10)

Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.SingleConnectionFactory

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1424)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1369)

... 10 more

写回答 关注

5回答

  • 磁单极
    2017-10-07 09:57:42
    已采纳

    spring集成jms的jar没有引进去!

    书策稠浊38...

    我的包引进去了,还是不行

    2017-12-11 23:17:59

    共 1 条回复 >

  • 慕工程4045380
    2018-03-01 15:10:46

    我也是同样的问题,4.2.5.RELEASE的版本一直没导进去,后来换了4.3.14的就可以,换成5.0.4的也可以

  • LeoRichard
    2018-02-13 12:52:26

    我也这样,不过吧spring版本从5改到4就好了,不知道你是不是

  • qq_对祢无语_0
    2017-12-16 15:19:37

    没办法创建连接池

  • qq_对祢无语_0
    2017-12-16 15:19:13

    我也是同样的问题

Java消息中间件

使用Java消息中间件处理异步消息

54146 学习 · 144 问题

查看课程

相似问题