欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot項(xiàng)目URL訪問異常的問題處理

 更新時(shí)間:2023年07月26日 10:02:52   作者:小chen愛學(xué)java  
這篇文章主要介紹了SpringBoot項(xiàng)目URL訪問異常的問題處理方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

SpringBoot項(xiàng)目URL訪問異常

一,啟動(dòng)類與所在包的組件的位置,一定要在同一個(gè)包并行,不能直接在java下;

二,訪問路徑問題,要與Controller一致;

三,是不是項(xiàng)目本身的問題呢,訪問URL后

{
? ? "timestamp": "2023-06-16 13:13:21",
? ? "status": 500,
? ? "error": "Internal Server Error",
? ? "message": "Invalid bound statement (not found): com.atguigu.yygh.hosp.mapper.HospitalSetMapper.selectList",
? ? "path": "/admin/hosp/hospitalSet/findAll"
}

問題在于:

"Invalid bound statement (not found): com.atguigu.yygh.hosp.mapper.HospitalSetMapper.selectList",

原因:

依賴放在父模塊的pom.xml文件中,子模塊沒有繼承到父模塊的依賴

<dependency>
? ? <groupId>com.baomidou</groupId>
? ? <artifactId>mybatis-plus-boot-starter</artifactId>
? ? <version>最新版本</version>
</dependency>

SpringBoot項(xiàng)目中數(shù)據(jù)庫的url 突然不能用

原因

我在啟動(dòng)springboot項(xiàng)目的時(shí)候,突然報(bào)了一個(gè)錯(cuò)誤

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


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).

找了老半天,才發(fā)現(xiàn)bug所在,是因?yàn)槲以谥盀榱艘雑ava包下的mybatis的mapper.xml文件,在pom,xml中引用了一下的代碼

<build>
? ? ? ? <resources>
? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? <!-- java文件中一般會(huì)忽略,因?yàn)槲覀兊膞ml文件是放在java文件下 所以我們要將它忽略,也就是要打包-->
? ? ? ? ? ? ? ? <directory>src/main/java</directory>
? ? ? ? ? ? ? ? <includes>
? ? ? ? ? ? ? ? ? ? <include>**/*.xml</include>
? ? ? ? ? ? ? ? </includes>
? ? ? ? ? ? ? ? <filtering>false</filtering>
? ? ? ? ? ? </resource>
? ? ? ? </resources>
? ? </build>

所以說 在resources文件夾下的yaml文件沒有能夠打包進(jìn)入

解決辦法

<build>
? ? ? ? <resources>
? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? <!-- java文件中一般會(huì)忽略,因?yàn)槲覀兊膞ml文件是放在java文件下 所以我們要將它忽略,也就是要打包-->
? ? ? ? ? ? ? ? <directory>src/main/java</directory>
? ? ? ? ? ? ? ? <includes>
? ? ? ? ? ? ? ? ? ? <include>**/*.xml</include>
? ? ? ? ? ? ? ? </includes>
? ? ? ? ? ? ? ? <filtering>false</filtering>
? ? ? ? ? ? </resource>
? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? <directory>src/main/resources</directory>
? ? ? ? ? ? ? ? <includes>
? ? ? ? ? ? ? ? ? ? <include>**/*.yaml</include>
? ? ? ? ? ? ? ? ? ? <include>**/*.properties</include>
? ? ? ? ? ? ? ? ? ? <include>**/*.xml</include>
? ? ? ? ? ? ? ? </includes>
? ? ? ? ? ? ? ? <filtering>false</filtering>
? ? ? ? ? ? </resource>
? ? ? ? </resources>
? ? </build>

這是我所遇到的問題的答案,下面是一些其他的解決方案。

其他解決方案

排除數(shù)據(jù)源的自動(dòng)配置類

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

檢查配置文件中的信息是否填寫正確

?datasource: # mysql數(shù)據(jù)庫連接
? ? ?type: com.zaxxer.hikari.HikariDataSource
? ? ?driver-class-name: com.mysql.cj.jdbc.Driver
? ? ?url: jdbc:mysql:///alibaba?serverTimezone=GMT%2B8&characterEncoding=utf-8
? ? ?username: root
? ? ?password: root

剩下還有比如 符號(hào)轉(zhuǎn)義,在properties和yaml文件中是不需要符號(hào)轉(zhuǎn)義的,這也是它所強(qiáng)大的一點(diǎn)

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java使用注解實(shí)現(xiàn)BigDecimal的四舍五入

    Java使用注解實(shí)現(xiàn)BigDecimal的四舍五入

    BigDecimal是Java中的一個(gè)類,位于java.math包中,它提供了任意精度的有符號(hào)十進(jìn)制數(shù)字的表示,以及對這些數(shù)字進(jìn)行算術(shù)運(yùn)算的方法,本文介紹了Java使用注解實(shí)現(xiàn)BigDecimal的四舍五入的相關(guān)知識(shí),需要的朋友可以參考下
    2024-09-09
  • SpringBoot3集成Kafka的方法詳解

    SpringBoot3集成Kafka的方法詳解

    Kafka是一個(gè)開源的分布式事件流平臺(tái),常被用于高性能數(shù)據(jù)管道、流分析、數(shù)據(jù)集成和關(guān)鍵任務(wù)應(yīng)用,下面我們就來看看SpringBoot3是如何集成Kafka的吧
    2023-08-08
  • springboot整合quartz實(shí)例demo

    springboot整合quartz實(shí)例demo

    Quartz是一個(gè)開源的任務(wù)調(diào)度框架?;诙〞r(shí)、定期的策略來執(zhí)行任務(wù)是它的核心功能,比如x年x月的每個(gè)星期五上午8點(diǎn)到9點(diǎn),每隔10分鐘執(zhí)行1次,本文重點(diǎn)給大家介紹springboot整合quartz的實(shí)例代碼,感興趣的朋友一起看看吧
    2022-02-02
  • 基于JAVA的短信驗(yàn)證碼api調(diào)用代碼實(shí)例

    基于JAVA的短信驗(yàn)證碼api調(diào)用代碼實(shí)例

    這篇文章主要為大家詳細(xì)介紹了基于JAVA的短信驗(yàn)證碼api調(diào)用代碼實(shí)例,感興趣的小伙伴們可以參考一下
    2016-05-05
  • SpringBoot?異步線程間傳遞上下文方式

    SpringBoot?異步線程間傳遞上下文方式

    這篇文章主要介紹了SpringBoot?異步線程間傳遞上下文方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-11-11
  • SpringBoot自動(dòng)重啟、熱啟動(dòng)方式

    SpringBoot自動(dòng)重啟、熱啟動(dòng)方式

    這篇文章主要介紹了SpringBoot自動(dòng)重啟、熱啟動(dòng)方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Java實(shí)現(xiàn)的日歷功能完整示例

    Java實(shí)現(xiàn)的日歷功能完整示例

    這篇文章主要介紹了Java實(shí)現(xiàn)的日歷功能,結(jié)合完整實(shí)例形式分析了Java日歷功能相關(guān)的日期時(shí)間獲取、計(jì)算、顯示等操作技巧,需要的朋友可以參考下
    2019-02-02
  • spring-boot.version2.6升級到2.7.18后security報(bào)錯(cuò)問題

    spring-boot.version2.6升級到2.7.18后security報(bào)錯(cuò)問題

    這篇文章主要介紹了spring-boot.version2.6升級到2.7.18后security報(bào)錯(cuò)問題及解決,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • 淺談Java線程池的7大核心參數(shù)

    淺談Java線程池的7大核心參數(shù)

    本篇文章基于正在看這篇文章的你已經(jīng)具備了基本的Java并發(fā)的相關(guān)知識(shí).如果對于Java并發(fā)編程一無所知的話,請先看看Java并發(fā)編程的一些前導(dǎo)基礎(chǔ)知識(shí),文中有非常詳細(xì)的圖文示例及代碼,,需要的朋友可以參考下
    2021-05-05
  • SpringMVC實(shí)現(xiàn)數(shù)據(jù)綁定及表單標(biāo)簽

    SpringMVC實(shí)現(xiàn)數(shù)據(jù)綁定及表單標(biāo)簽

    這篇文章主要為大家詳細(xì)介紹了SpringMVC實(shí)現(xiàn)數(shù)據(jù)綁定及表單標(biāo)簽的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03

最新評論