解決springboot+activemq啟動(dòng)報(bào)注解錯(cuò)誤的問題
springboot+activemq啟動(dòng)報(bào)注解錯(cuò)誤
Description:
Field jmsMessagingTemplate in com.haozz.demo.mq.PromoteActProducer required a bean of type 'org.springframework.jms.core.JmsMessagingTemplate' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
The following candidates were found but could not be injected:
- Bean method 'jmsMessagingTemplate' in 'JmsAutoConfiguration.MessagingTemplateConfiguration' not loaded because Ancestor org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration did not match
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.jms.core.JmsMessagingTemplate' in your configuration.
原因總結(jié)有以下3點(diǎn)原因:
1.spring.activemq.pool.enabled=true,線程池開啟,后面有空格,且沒有引入線程池包
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> </dependency>
2.springboot版本問題不支持,建議用2.0版本啟動(dòng)
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent>
猜想:估計(jì)是因?yàn)?.1.0+版本有自己的線程池管理,導(dǎo)致沖突
3.spring.activemq.pool.enabled=false,關(guān)閉線程池
springboot整合activemq踩過坑
啟動(dòng)時(shí)候就關(guān)閉了
配置如下
server: port: 8762 # context-path: /memeber eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ spring: application: name: member redis: host: 127.0.0.1 password: 123456 port: 6379 pool: max-idle: 100 min-idle: 1 max-active: 1000 max-wait: -1 datasource: name: test1 url: jdbc:mysql://127.0.0.1:3306/dandan-member username: root password: 123456 type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat maxActive: 20 initialSize: 1 maxWait: 60000 minIdle: 1 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 ##activemq連接信息 activemq: broker-url: tcp://localhost:61616 in-memory: true pool: enabled: false ##隊(duì)列 messages: queue: messages_queue
解決如下
原本activemq 沒有在spring.后面直接在前面了,與spring同級(jí)了
解決后配置如下
server: port: 8762 # context-path: /memeber eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ spring: application: name: member redis: host: 127.0.0.1 password: 123456 port: 6379 pool: max-idle: 100 min-idle: 1 max-active: 1000 max-wait: -1 datasource: name: test1 url: jdbc:mysql://127.0.0.1:3306/dandan-member username: root password: 123456 type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat maxActive: 20 initialSize: 1 maxWait: 60000 minIdle: 1 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 ##activemq連接信息 activemq: broker-url: tcp://localhost:61616 in-memory: true pool: enabled: false ##隊(duì)列 messages: queue: messages_queue
建議。yml縮進(jìn)要四個(gè)字節(jié)。一個(gè)字節(jié)不容易分辨
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- springboot項(xiàng)目啟動(dòng),但是訪問報(bào)404錯(cuò)誤的問題
- 記一次springboot配置redis項(xiàng)目啟動(dòng)時(shí)的一個(gè)奇怪的錯(cuò)誤
- 解決Springboot啟動(dòng)報(bào)錯(cuò):類文件具有錯(cuò)誤的版本61.0,應(yīng)為?52.0
- 啟動(dòng)springboot項(xiàng)目時(shí)報(bào)錯(cuò):無法訪問org.springframework.web.bind.annotation.GetMapping …具有錯(cuò)誤的版本 61.0,應(yīng)為52.0?的解決方案
- SpringBoot項(xiàng)目啟動(dòng)打包報(bào)錯(cuò)類文件具有錯(cuò)誤的版本 61.0, 應(yīng)為 52.0的解決方法
- 啟動(dòng)SpringBoot報(bào)JavaMail加載錯(cuò)誤的原因分析和解決
- springboot項(xiàng)目啟動(dòng)類錯(cuò)誤(找不到或無法加載主類 com.**Application)
- spring boot啟動(dòng)出現(xiàn)Unable to start ServletWebServerApplicationContext due to missing ServletWebServer錯(cuò)誤解決
相關(guān)文章
Java之SpringCloud nocos注冊(cè)中心講解
這篇文章主要介紹了Java之SpringCloud nocos注冊(cè)中心講解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08Java類中this關(guān)鍵字與static關(guān)鍵字的用法解析
這篇文章主要介紹了Java類中this關(guān)鍵字與static關(guān)鍵字的用法解析,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09關(guān)于@Scheduled注解的任務(wù)為什么不執(zhí)行的問題
這篇文章主要介紹了關(guān)于@Scheduled注解的任務(wù)為什么不執(zhí)行的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09Java超詳細(xì)教你寫一個(gè)斗地主洗牌發(fā)牌系統(tǒng)
這篇文章主要介紹了怎么用Java來你寫一個(gè)斗地主種洗牌和發(fā)牌的功能,斗地主相信大家都知道,同時(shí)也知道每一局都要洗牌打亂順序再發(fā)牌,本篇我們就來實(shí)現(xiàn)這個(gè)功能,感興趣的朋友跟隨文章往下看看吧2022-03-03springboot自動(dòng)配置沒有生效的問題定位(條件斷點(diǎn))
這篇文章主要介紹了springboot自動(dòng)配置未生效問題定位,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,下面我們來學(xué)習(xí)一下吧2019-06-06