解決springboot+activemq啟動報注解錯誤的問題
springboot+activemq啟動報注解錯誤
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.
原因總結有以下3點原因:
1.spring.activemq.pool.enabled=true,線程池開啟,后面有空格,且沒有引入線程池包
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
2.springboot版本問題不支持,建議用2.0版本啟動
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
猜想:估計是因為2.1.0+版本有自己的線程池管理,導致沖突
3.spring.activemq.pool.enabled=false,關閉線程池
springboot整合activemq踩過坑

啟動時候就關閉了
配置如下
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
##隊列
messages:
queue: messages_queue
解決如下
原本activemq 沒有在spring.后面直接在前面了,與spring同級了
解決后配置如下
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
##隊列
messages:
queue: messages_queue
建議。yml縮進要四個字節(jié)。一個字節(jié)不容易分辨
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- springboot項目啟動,但是訪問報404錯誤的問題
- 記一次springboot配置redis項目啟動時的一個奇怪的錯誤
- 解決Springboot啟動報錯:類文件具有錯誤的版本61.0,應為?52.0
- 啟動springboot項目時報錯:無法訪問org.springframework.web.bind.annotation.GetMapping …具有錯誤的版本 61.0,應為52.0?的解決方案
- SpringBoot項目啟動打包報錯類文件具有錯誤的版本 61.0, 應為 52.0的解決方法
- 啟動SpringBoot報JavaMail加載錯誤的原因分析和解決
- springboot項目啟動類錯誤(找不到或無法加載主類 com.**Application)
- spring boot啟動出現(xiàn)Unable to start ServletWebServerApplicationContext due to missing ServletWebServer錯誤解決
相關文章
Java反射獲取所有Controller和RestController類的方法
這篇文章給大家分享了Java反射獲取所有Controller和RestController類的方法,文中有詳細的代碼示例講解,具有一定的參考價值,需要的朋友可以參考下2023-08-08
springboot配置文件屬性變量引用方式${}和@@用法及區(qū)別說明
這篇文章主要介紹了springboot配置文件屬性變量引用方式${}和@@用法及區(qū)別說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03
SpringBoot對數(shù)據(jù)訪問層進行單元測試的方法詳解
我們公司作為一個面向銀行、金融機構的TO B類企業(yè),頻繁遇到各個甲方爸爸提出的國產(chǎn)化數(shù)據(jù)庫的改造需求,包括OceanBase, TiDB,geldenDB等等,本文就介紹一種快高效、可復用的解決方案——對數(shù)據(jù)訪問層做單元測試,需要的朋友可以參考下2023-08-08
SpringBoot整合Swagger3生成接口文檔的示例代碼
Swagger 是一個 RESTful API 的開源框架,它的主要目的是幫助開發(fā)者設計、構建、文檔化和測試 Web API,本文給大家介紹了SpringBoot整合Swagger3生成接口文檔的流程,并通過代碼講解的非常詳細,需要的朋友可以參考下2024-04-04
Java中使用內(nèi)存映射實現(xiàn)大文件上傳實例
這篇文章主要介紹了Java中使用內(nèi)存映射實現(xiàn)大文件上傳實例,本文對比測試了FileInputStream 或者FileOutputStream 抑或RandomAccessFile的頻繁讀寫操作,最后總結出映射到內(nèi)存后進行讀寫以提高速度,需要的朋友可以參考下2015-01-01

