最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot啟動(dòng)失敗的原因及其解決方法

 更新時(shí)間:2024年06月27日 09:42:02   作者:沖鋒的禾  
對(duì)于springboot的啟動(dòng)失敗,相信大家都有經(jīng)歷,但是為什么會(huì)啟動(dòng)失敗,以及怎么解決都只能通過日志進(jìn)行查看,在這里,我會(huì)將常見的springboot啟動(dòng)失敗的報(bào)錯(cuò)一一展示,需要的朋友可以參考下

前言:

對(duì)于springboot的啟動(dòng)失敗,相信大家都有經(jīng)歷,但是為什么會(huì)啟動(dòng)失敗,以及怎么解決都只能通過日志進(jìn)行查看,在這里,我會(huì)將常見的springboot啟動(dòng)失敗的報(bào)錯(cuò)一一展示

報(bào)錯(cuò):

1:端口占用報(bào)錯(cuò)

***************************
APPLICATION FAILED TO START
***************************
 
Description:
The Tomcat connector configured to listen on port 8987 failed to start. The port  may already be in use or the connector may be misconfigured.
 
// 配置為監(jiān)聽端口8987的Tomcat連接器啟動(dòng)失敗。端口可能已經(jīng)在使用中,或者連接器可能配置錯(cuò)誤。
 
Action:
Verify the connector's configuration, identify and stop any process that's liste ning on port 8987, or configure this application to listen on another port.
 
// 驗(yàn)證連接器的配置,識(shí)別并停止端口8987上正在運(yùn)行的任何進(jìn)程,或?qū)⒋藨?yīng)用程序配置為監(jiān)聽另一個(gè)端口。
  • 報(bào)錯(cuò):The port may already be in use  —>  端口可能已經(jīng)在使用中
  • 原因:8987 端口被占用
  • 解決:給springboot換一個(gè)端口或關(guān)閉占用端口的程序。

2:mapper掃描類報(bào)錯(cuò)

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Field clustersDetailsAmqMapper in com.ruoyi.clusters.service.impl.ClustersDetailsAmqServiceImpl required a bean of type 'com.ruoyi.clusters.mapper.ClustersDetailsAmqMapper' that could not be found.
 
// 在 com.ruoyi.clusters.service.impl.ClustersDetailsAmqServiceImpl 中的屬性 clustersDetailsAmqMapper 需要一個(gè)類型為'com.ruoyi.clusters.mapper.ClustersDetailsAmqMapper'的bean,但是找不到它。
 
The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)
 
// 注入點(diǎn)具有以下注釋:-@org.springframework.beans.factory.annotation.Autowired(必需=true)
 
Action:
 
Consider defining a bean of type 'com.ruoyi.clusters.mapper.ClustersDetailsAmqMapper' in your configuration.
 
// 考慮在配置中定義一個(gè)類型為'com.ruoyi.clusters.mapper.ClustersDetailsAmqMapper'的bean。
  • 報(bào)錯(cuò):Field xxxMapper in xxx required a bean of type 'xxxMapper' that could not be found. —> 在xxx中的屬性xxxMapper 需要一個(gè)類型為'xxxMapper'的 bean,但是找不到它。
  • 原因:springboot的啟動(dòng)類 沒有配置mapper掃描路徑 或 配置的mapper文件掃描路徑不對(duì)。
  • 解決:在springboot啟動(dòng)類中 配置正確的mapper文件掃描,如下:
@SpringBootApplication
@MapperScan(value = "com.ruoyi.**.mapper")  
// 路徑必須與mapper文件在的路徑一致,否則依然會(huì)報(bào)錯(cuò)
public class RuoYiApplication {
    public static void main(String[] args) {
        SpringApplication.run(RuoYiApplication.class, args);
    }
}

注意:* 指的是下一級(jí)目錄,** 指的是包含其子目錄在內(nèi)的。

如果Mapper文件在com.ruoyi.testa.mapper中,用@MapperScan(value = "com.ruoyi.*.mapper") 是可以的,

如果文件是在com.ruoyi.testa.mytest.mapper中,1個(gè) * 配置依然會(huì)找不到這個(gè)Mapper文件,會(huì)報(bào)同樣的錯(cuò)誤,應(yīng)該用**,@MapperScan(value = "com.ruoyi.**.mapper")。
 

3.數(shù)據(jù)庫連接問題

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
// 配置數(shù)據(jù)源失?。簺]有指定'url'屬性,無法配置嵌入的數(shù)據(jù)源。
 
Reason: Failed to determine a suitable driver class
// 原因:無法確定合適的驅(qū)動(dòng)程序類
 
Action:
 
Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
// 請(qǐng)考慮以下幾點(diǎn):
// 如果你想要嵌入式數(shù)據(jù)庫(H2、HSQL或Derby),請(qǐng)把它放在classpath(類路徑)上。
// 如果要從特定配置文件加載數(shù)據(jù)庫設(shè)置,則可能需要激活它(當(dāng)前沒有配置文件處于活動(dòng)狀態(tài))。

報(bào)錯(cuò):Failed to determine a suitable driver class  —> 沒法確定合適的驅(qū)動(dòng)程序類

原因:沒有在application.yml中配置數(shù)據(jù)源(比如druid連接池)或 數(shù)據(jù)庫驅(qū)動(dòng)(比如mysql)

加上數(shù)據(jù)源配置:

# 數(shù)據(jù)源配置
spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: com.mysql.cj.jdbc.Driver
        druid:
            # 主庫數(shù)據(jù)源
            master:
                url: jdbc:mysql://127.0.0.1:3306/car?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                username: root
                password: root

加上數(shù)據(jù)庫坐標(biāo):

 <!-- Mysql驅(qū)動(dòng)包 -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

4:沒有綁定連接池

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Failed to bind properties under 'spring.datasource.type' to java.lang.Class<javax.sql.DataSource>:
// 沒法把'spring.datasource.type'下的屬性綁定到j(luò)ava.lang.Class<javax.sql.datasource>:
    Property: spring.datasource.type
    // 屬性:spring.datasource.type
    Value: com.alibaba.druid.pool.DruidDataSource
    // 值: com.alibaba.druid.pool.DruidDataSource
    Origin: class path resource [application-druid.yml]:4:15
    //來源: 類路徑資源[application-druid.yml]:4:15
    Reason: No converter found capable of converting from type [java.lang.String] to type [java.lang.Class<javax.sql.DataSource>]
// 原因:找不到能夠從類型[java.lang.String]轉(zhuǎn)換為類型[java.lang.Class<javax.sql.DataSource>]的轉(zhuǎn)換器
 
Action:
 
Update your application's configuration
// 更新應(yīng)用程序的配置

原因:沒導(dǎo)入Druid連接池的坐標(biāo),所以找不到com.alibaba.druid.pool.DruidDataSource,把Druid連接池的坐標(biāo)正確導(dǎo)入即可

<!--阿里數(shù)據(jù)庫連接池 -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
</dependency>

5:無法確定合適的jdbc url

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
// 配置數(shù)據(jù)源失?。簺]有指定“url”屬性,無法配置嵌入的數(shù)據(jù)源。
 
Reason: Failed to determine suitable jdbc url
// 原因:無法確定合適的jdbc url
 
Action:
 
Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
// 請(qǐng)考慮以下幾點(diǎn):
// 如果你想要嵌入式數(shù)據(jù)庫(H2、HSQL或Derby),請(qǐng)把它放在類路徑上。
// 如果要從特定配置文件加載數(shù)據(jù)庫設(shè)置,則可能需要激活它(當(dāng)前沒有激活的配置文件)。
報(bào)錯(cuò):Failed to determine suitable jdbc url  —> 無法確定合適的jdbc url
原因:

url沒有被讀取到,配置文件沒有生效,其大概原因有以下幾點(diǎn):

系統(tǒng)編碼不正確。跑項(xiàng)目之前最好讓項(xiàng)目與文件的編碼對(duì)應(yīng)起來
可能有和你所在項(xiàng)目平級(jí)的配置文件,springboot會(huì)優(yōu)先讀取項(xiàng)目同級(jí)別目錄下的配置文件
idea沒有將resource設(shè)置為資源目錄
檢查DruidConfig配置類(或配置文件)
檢查一下Application啟動(dòng)文件的位置,建議將其放在外層:如果SpringBootApplication啟動(dòng)文件位置在數(shù)據(jù)庫配置DruidConfig文件下層,則不會(huì)對(duì)這個(gè)Configuration進(jìn)行掃描,然后去找默認(rèn)的配置,所以導(dǎo)致Failed to determine suitable jdbc url

6:自定義數(shù)據(jù)源一定要排除SpringBoot自動(dòng)配置數(shù)據(jù)源,不然會(huì)出現(xiàn)循環(huán)引用的問題

Description:
 
The dependencies of some of the beans in the application context form a cycle:
// 應(yīng)用程序上下文中某些bean的依賴關(guān)系形成一個(gè)循環(huán):
 
   testAController (field private com.ruoyi.testa.service.TestAService com.ruoyi.apis.TestAController.testAService)
      ↓
   testAServiceImpl (field private com.ruoyi.testa.mapper.TestAMapper com.ruoyi.testa.service.impl.TestAServiceImpl.testAMapper)
      ↓
   testAMapper defined in file [E:\IdeaProjects2018\car\ruoyi-mapper\target\classes\com\ruoyi\testa\mapper\TestAMapper.class]
      ↓
   sqlSessionFactory defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]
┌─────┐
|  dynamicDataSource defined in class path resource [com/ruoyi/config/DruidConfig.class]
↑     ↓
|  masterDataSource defined in class path resource [com/ruoyi/config/DruidConfig.class]
↑     ↓
|  org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker
└─────┘
  • 異常出現(xiàn)場(chǎng)景:SpringBoot中自定義DataSource數(shù)據(jù)源
  • 原因:自定義數(shù)據(jù)源一定要排除SpringBoot自動(dòng)配置數(shù)據(jù)源,不然會(huì)出現(xiàn)循環(huán)引用的問題。
  • 解決:排除Spring Boot數(shù)據(jù)源自動(dòng)配置類
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan(value = "com.ruoyi.**.mapper") 
public class RuoYiApplication {
    public static void main(String[] args) {
        SpringApplication.run(RuoYiApplication.class, args);
    }
}

7:由于缺少ServletWebServerFactory bean,無法啟動(dòng)ServletWebServerApplicationContext

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.3.RELEASE)
2020-09-01 11:21:54.103  INFO 21308 --- [           main] com.smr.bluetooth.DeviceCommApplication  : Starting DeviceCommApplication on LAPTOP-RM7CN477 with PID 21308 (E:\IdeaProjects2018\bluetooth_test\target\classes started by 且隨疾風(fēng)前行 in E:\IdeaProjects2018\bluetooth_test)
2020-09-01 11:21:54.106  INFO 21308 --- [           main] com.smr.bluetooth.DeviceCommApplication  : No active profile set, falling back to default profiles: default
2020-09-01 11:21:54.133  INFO 21308 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@770c2e6b: startup date [Tue Sep 01 11:21:54 CST 2020]; root of context hierarchy
2020-09-01 11:21:54.232  WARN 21308 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
2020-09-01 11:21:54.605 ERROR 21308 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at com.smr.bluetooth.DeviceCommApplication.main(DeviceCommApplication.java:10) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:204) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	... 8 common frames omitted

報(bào)錯(cuò):Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean. (由于缺少ServletWebServerFactory bean,無法啟動(dòng)ServletWebServerApplicationContext)

解決:啟動(dòng)類添加@EnableAutoConfiguration注解即可解決問題

8:依賴沖突

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
An attempt was made to call a method that does not exist. The attempt was made from the following location:
 
org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1319)
 
The following method did not exist:
 
javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
 
The calling method's class, org.apache.catalina.authenticator.AuthenticatorBase, was loaded from the following location:
jar:file:/E:/Maven/maven-repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.63/tomcat-embed-core-9.0.63.jar!/org/apache/catalina/authenticator/AuthenticatorBase.class
The called method's class, javax.servlet.ServletContext, is available from the following locations:
 
jar:file:/E:/Maven/maven-repository/org/apache/tomcat/servlet-api/6.0.18/servlet-api-6.0.18.jar!/javax/servlet/ServletContext.class
jar:file:/E:/Maven/maven-repository/org
  • 報(bào)錯(cuò):An attempt was made to call a method that does not exist.(試圖調(diào)用不存在的方法。)
  • 原因:依賴沖突
  • 解決:
  • 1.先重新編譯運(yùn)行試下

2.排查是否是版本不兼容、版本沖突等

以上就是SpringBoot啟動(dòng)失敗的原因及其解決方法的詳細(xì)內(nèi)容,更多關(guān)于SpringBoot啟動(dòng)失敗的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • MyBatis動(dòng)態(tài)SQL如何實(shí)現(xiàn)前端指定返回字段

    MyBatis動(dòng)態(tài)SQL如何實(shí)現(xiàn)前端指定返回字段

    這篇文章主要介紹了MyBatis動(dòng)態(tài)SQL如何實(shí)現(xiàn)前端指定返回字段,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • SpringCloud的JPA連接PostgreSql的教程

    SpringCloud的JPA連接PostgreSql的教程

    這篇文章主要介紹了SpringCloud的JPA接入PostgreSql 教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-06-06
  • springboot+vue部署按照及運(yùn)行方法

    springboot+vue部署按照及運(yùn)行方法

    在本篇文章里小編給大家整理了關(guān)于springboot+vue部署按照及運(yùn)行方法和實(shí)例內(nèi)容,需要的朋友們學(xué)習(xí)參考下。
    2020-01-01
  • IntelliJ IDEA中加速M(fèi)aven編譯的終極指南

    IntelliJ IDEA中加速M(fèi)aven編譯的終極指南

    這篇文章主要為大家詳細(xì)介紹了IntelliJ IDEA中加速M(fèi)aven編譯的終極指南,從 7 分鐘提速到 30 秒,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2025-10-10
  • Java日常練習(xí)題,每天進(jìn)步一點(diǎn)點(diǎn)(24)

    Java日常練習(xí)題,每天進(jìn)步一點(diǎn)點(diǎn)(24)

    下面小編就為大家?guī)硪黄狫ava基礎(chǔ)的幾道練習(xí)題(分享)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧,希望可以幫到你
    2021-07-07
  • 你真的會(huì)使用Java的方法引用嗎

    你真的會(huì)使用Java的方法引用嗎

    這篇文章主要給大家介紹了關(guān)于Java方法引用的相關(guān)資料,方法引用是Java8的新特性,方法引用其實(shí)也離不開Lambda表達(dá)式,本文通過示例代碼介紹的很詳細(xì),需要的朋友可以參考下
    2021-08-08
  • 解決jackson反序列化失敗InvalidFormatException:Can not deserialize value of type java.util.Date

    解決jackson反序列化失敗InvalidFormatException:Can not dese

    這篇文章主要介紹了解決jackson反序列化失敗InvalidFormatException:Can not deserialize value of type java.util.Date問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • springboot命令行啟動(dòng)的方法詳解

    springboot命令行啟動(dòng)的方法詳解

    這篇文章主要介紹了springboot命令行啟動(dòng)的方法,本文通過兩種方法給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • 詳解Spring Boot自動(dòng)裝配的方法步驟

    詳解Spring Boot自動(dòng)裝配的方法步驟

    這篇文章主要介紹了詳解Spring Boot自動(dòng)裝配的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • MyBatis-plus中的模糊查詢解讀

    MyBatis-plus中的模糊查詢解讀

    這篇文章主要介紹了MyBatis-plus中的模糊查詢解讀,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05

最新評(píng)論

三河市| 霍邱县| 施甸县| 静乐县| 大竹县| 五河县| 泽州县| 怀远县| 云阳县| 饶河县| 温泉县| 白山市| 新余市| 潞西市| 高台县| 赫章县| 兰考县| 盐源县| 郓城县| 丽江市| 青河县| 法库县| 长寿区| 贞丰县| 新化县| 伊金霍洛旗| 博乐市| 安西县| 南开区| 松原市| 长武县| 邯郸市| 吴川市| 渝北区| 白水县| 盐边县| 云和县| 漳浦县| 平塘县| 鞍山市| 师宗县|