亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

springboot 沒法掃描到repository的解決

瀏覽:6日期:2023-03-27 09:17:08

sprint boot2.0啟動(dòng)的時(shí)候報(bào)錯(cuò)!

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

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

我先用@ComponentScan注解加上類所在的包名,沒有報(bào)錯(cuò),可以正常啟動(dòng)

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

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

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

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

這個(gè)是因?yàn)樽铋_始的時(shí)候項(xiàng)目啟動(dòng)報(bào)錯(cuò)沒有數(shù)據(jù)庫相關(guān)配置

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

spring.datasource.url=jdbc:mysql://xxx.x.x.x/favorites?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=truespring.datasource.username=rootspring.datasource.password=rootspring.datasource.driver-class-name=com.mysql.jdbc.Driver

這里的數(shù)據(jù)庫不是我本機(jī)的數(shù)據(jù)庫,但是日志一直是報(bào)錯(cuò)連接的是連接我的本地?cái)?shù)據(jù)庫失敗

報(bào)錯(cuò)信息里查了一下DataSourceConfiguration這個(gè)類,猜測是配置的數(shù)據(jù)庫連接失敗之后開始連接localhost的數(shù)據(jù)庫

然后加上了hikari的一些配置就能正常啟動(dòng),連接我配置的數(shù)據(jù)庫,查詢sql都正常了

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

定位過程真的是好心累!

補(bǔ)充:今天安裝spring的時(shí)候遇到一些缺少repository的問題

在安裝spring的時(shí)候會(huì)對(duì)其依賴的一些庫的進(jìn)行一些鏈接檢查,導(dǎo)致會(huì)報(bào)一些缺少repository的問題

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

stackvoerflow上找到了對(duì)應(yīng)的問題和解決方案:地址

解決方法:

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

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 欧美一级特黄毛片免费 | aaaaaa级特色特黄的毛片 | 草草影院一级毛片a级 | 色爱综合区 | 视频一区 在线 | 亚洲欧美日韩成人一区在线 | 亚洲日韩精品欧美一区二区 | 久久视频精品36线视频在线观看 | 大陆一级毛片免费视频观看i | 青青青国产视频 | 图片一区 | 国产福利视频一区二区微拍 | 国产好大好爽久久久久久久 | 日本美女一区二区 | 日本xxxxx护士16 | 永久免费影院 | 国产精品久久久久久久久久久久久久 | 成人一级片 | 九草视频在线 | 任我鲁这里有精品视频在线播 | 欧美一级毛级毛片 | 中文字幕永久在线视频 | 在线精品小视频 | aⅴ一区二区三区无卡无码 aⅴ在线免费观看 | 欧美ol丝袜高跟秘书在线播放 | 国产精品欧美一区二区在线看 | 欧洲精品在线视频 | 国模精品一区二区三区 | 欧美日韩国产成人精品 | 国产一级黄色网 | 成人免费视频在线播放 | 2021国产麻豆剧传媒精品网站 | 鸥美黄色片 | 欧美a级片视频 | 精品国产一区二区三区四区色 | 高清国产精品入口麻豆 | 国产乱人免费视频 | 特大巨黑人吊与黑人性xxxx | 久久精品天天爽夜夜爽 | 亚洲一区有码 | 麻豆果冻国产91在线极品 |