码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • SpringBoot - Failed to determine a suitable driver class


    报错问题

    关键信息:Description: Failed to auto-configure a DataSource: ‘spring.datasource.url’ is not
    specified and no embedded datasource could be auto-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)

    原因分析

    启动时加载配置文件失败,异常报错,启动失败(网上有些人遇到启动时本不需要加载数据源,却加载了,导致这个问题)

    解决方案

    • 方法一(启动时加载本不需要加载的数据源)
    1. @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
    2. public class SpringBootApplication {
    3. public static void main(String[] args) {
    4. SpringApplication.run(MySpringBootApplication.class,args);
    5. }
    6. }

    Ps:exclude = DataSourceAutoConfiguration.class 加上这段代码,去掉数据源

    • 方法二(有数据源依旧报错,配置文件没有加载成功)
    1. <build>
    2. <resources>
    3. <resource>
    4. <directory>src/main/java</directory>
    5. <includes>
    6. <include>**/*.properties</include>
    7. <include>**/*.xml</include>
    8. </includes>
    9. <filtering>true</filtering>
    10. </resource>
    11. <resource>
    12. <directory>src/main/resources</directory>
    13. <includes>
    14. <include>*</include>
    15. <include>*/*</include>
    16. </includes>
    17. <filtering>true</filtering>
    18. </resource>
    19. </resources>
    20. <plugins>
    21. <plugin>
    22. <groupId>org.apache.maven.plugins</groupId>
    23. <artifactId>maven-surefire-plugin</artifactId>
    24. <version>3.0.0-M1</version>
    25. <configuration>
    26. <useSystemClassLoader>false</useSystemClassLoader>
    27. </configuration>
    28. </plugin>
    29. <plugin>
    30. <groupId>org.apache.maven.plugins</groupId>
    31. <artifactId>maven-compiler-plugin</artifactId>
    32. <version>3.3</version>
    33. <configuration>
    34. <source>1.8</source>
    35. <target>1.8</target>
    36. <encoding>UTF-8</encoding>
    37. <testIncludes>
    38. <testInclude>none</testInclude>
    39. </testIncludes>
    40. <compilerArguments>
    41. <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
    42. </compilerArguments>
    43. </configuration>
    44. </plugin>
    45. </plugins>
    46. </build>

    Ps:可以尝试在pom.xml文件的build标签中加入以上内容

  • 相关阅读:
    CANoe-vTESTstudio之Test Diagram编辑器(元素介绍)
    [附源码]java毕业设计海南生鲜冷链物流配送系统论文
    学习黑马程序员JavaScript总结
    简述@RequestParam与@RequestBody参数注解
    【圣诞节限定】教你用Python画圣诞树,做个浪漫的程序员
    C语言【空字符】和【空指针】
    Java和Python中20个基本编程面试问题
    智慧公厕是对智慧城市“神经末梢”的有效激活,公共厕所实现可感知、可视化、可管理、可控制
    【Shell 脚本速成】03、Shell 脚本实战案例(一)数据磁盘初始化
    红帽认证 | RHCE考试包括哪些内容?
  • 原文地址:https://blog.csdn.net/Dream_Weave/article/details/125620487
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号