婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > springboot 沒法掃描到repository的解決

springboot 沒法掃描到repository的解決

熱門標簽:電銷機器人能補救房產中介嗎 天津開發區地圖標注app 400電話申請客服 地圖標注要花多少錢 電話機器人怎么換人工座席 移動外呼系統模擬題 濟南外呼網絡電話線路 江蘇400電話辦理官方 廣州電銷機器人公司招聘

sprint boot2.0啟動的時候報錯!

A component required a bean of type 'XXX' that could not be found.

就是沒有掃描到我的repository包里的代碼

我先用@ComponentScan注解加上類所在的包名,沒有報錯,可以正常啟動

但是坑爹的是@RestController注解下的Controller層的代碼沒有掃描到

就是說http://127.0.0.1:8080可以正常訪問,但是Controller層配置的@RequestMapping都匹配不到

折騰了好久好久,比如@ComponentScan在加上Controller層的包名還是不行(導致repository包掃描不到),使用包名.*模糊匹配也不行,好坑爹,說好的比spring mvc配置要簡單的呢

最后我盯上了@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)注解

這個是因為最開始的時候項目啟動報錯沒有數據庫相關配置

然后我刪掉了注解里的exclude,開始加上一些數據庫配置,比如

spring.datasource.url=jdbc:mysql://xxx.x.x.x/favorites?useUnicode=truecharacterEncoding=utf-8serverTimezone=UTCuseSSL=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

這里的數據庫不是我本機的數據庫,但是日志一直是報錯連接的是連接我的本地數據庫失敗

報錯信息里查了一下DataSourceConfiguration這個類,猜測是配置的數據庫連接失敗之后開始連接localhost的數據庫

然后加上了hikari的一些配置就能正常啟動,連接我配置的數據庫,查詢sql都正常了

spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1

定位過程真的是好心累!

補充:今天安裝spring的時候遇到一些缺少repository的問題

在安裝spring的時候會對其依賴的一些庫的進行一些鏈接檢查,導致會報一些缺少repository的問題

No repository found containing: osgi.bundle,oracle.eclipse.tools.rest.lib,16.4.0.201705251324
No repository found containing: osgi.bundle,org.eclipse.cft.server.core,1.2.3.v201709130027
No repository found containing: osgi.bundle,org.eclipse.cft.server.rse,1.0.1.v201709130027
No repository found containing: osgi.bundle,org.eclipse.cft.server.standalone.core,1.0.4.v201709130027
No repository found containing: osgi.bundle,org.eclipse.cft.server.standalone.ui,1.0.4.v201709130027
No repository found containing: osgi.bundle,org.eclipse.cft.server.ui,1.0.110.v201709130027

stackvoerflow上找到了對應的問題和解決方案:地址

解決方法:

Go to Help → Install new software → Here uncheck “Contact all update sites during install to find required software”

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

您可能感興趣的文章:
  • springboot掃描引入jar包的service等組件方式
  • SpringBoot掃描不到Controller的解決方案
  • Springboot 掃描mapper接口的2種操作
  • springboot bean掃描路徑的實現
  • Springboot自動掃描包路徑來龍去脈示例詳解
  • SpringBoot整合Mybatis無法掃描xml文件的解決
  • springboot啟動掃描不到dao層接口的解決方案

標簽:海西 杭州 濮陽 辛集 溫州 寶雞 榆林 昭通

巨人網絡通訊聲明:本文標題《springboot 沒法掃描到repository的解決》,本文關鍵詞  springboot,沒法,掃描,到,repository,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《springboot 沒法掃描到repository的解決》相關的同類信息!
  • 本頁收集關于springboot 沒法掃描到repository的解決的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 伊金霍洛旗| 普洱| 大冶市| 汨罗市| 喀喇沁旗| 东乡| 综艺| 衢州市| 屏边| 丰城市| 金秀| 天祝| 达拉特旗| 察雅县| 桃园县| 土默特左旗| 岑巩县| 建水县| 本溪市| 高碑店市| 兰州市| 雅安市| 定结县| 六盘水市| 陆良县| 漳平市| 建湖县| 象山县| 余庆县| 麻阳| 津市市| 达日县| 拉萨市| 通辽市| 绥化市| 新绛县| 大姚县| 景德镇市| 广德县| 都安| 招远市|