首页 > 其他分享 >springboot启动报错

springboot启动报错

时间:2023-01-10 14:58:59浏览次数:34  
标签:springboot 23 spring 启动 报错 mysql main class

前言

​ 学习构建spring boot+maven项目,在父模块下创建的一个新的模块,依赖版本由父模块pom.xml控制;写了一个测试接口,启动测试时,一直报错,初始化失败、datasource创建失败、没有合适的驱动,同时tomcat启动端口号也跟yml中不一致;

2023-01-09 23:23:37.192  WARN 15424 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2023-01-09 23:23:37.195  INFO 15424 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-01-09 23:23:37.210  INFO 15424 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-09 23:23:37.222 ERROR 15424 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

排查

  • 数据库MySQL5.7.30
    • 驱动:com.mysql.jdbc.Driver
    • 连接地址、账号、密码无误
spring:
  # 配置mysql数据源
  datasource:
    druid:
      username: root
      password: root
      url: jdbc:mysql://localhost:3306/stock_db
      driver-class-name: com.mysql.jdbc.Driver
  • 检查spring各依赖版本一致

  • 修改子工程pom.xml打包方式为jar,还是报错

  • 网上查到,application类加注解,先把数据库连接信息过滤掉;

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
  • 父模块工程执行install,启动成功

之前只是重新install过子模块,但是pom.xml中添加了maven打包的插件spring-boot-maven-plugin,暂时还想不明白

标签:springboot,23,spring,启动,报错,mysql,main,class
From: https://www.cnblogs.com/CHEN-zuhe/p/17040265.html

相关文章

  • vue3项目开源项目运行报错::v-deep usage as a combinator has been deprecated. Use
    今天找了一个vue3.0开源项目,在运行的时候npmi报错使用了npmi--legacy-peer-deps根据以上安装依赖成功在运行的时候有报错::v-deepusageasacombinatorhasbeend......
  • springboot集成dubbo
    使用SpringBoot+Dubbo搭建一个简单分布式服务实战之前,先来看几个重要的概念什么是分布式?什么是Duboo?Dubbo架构什么是RPC?为什么要用Dubbo?开始实战1:zoo......
  • Brew报错:Version value must be a string; got a NilClass () (TypeError)
    今天使用brew更新软件时,大概是因为太长时间没有更新了,出现了以下错误信息:UpdatingHomebrew...Traceback(mostrecentcalllast): 11:from/usr/local/Homebrew/Libr......
  • springboot_yaml与properties区别
    application.properties##springboot这个配置文件可以配置什么的东西呢?##第一种:背官方的配置,呜呜呜太多了##然后,官方推荐视图.yaml代替.properties#key=value,......
  • SpringBoot设置跨域的几种方式
    什么是跨域?浏览器从一个域名的网页去请求另一个域名的资源时,域名、端口、协议任一不同,都是跨域 原因:由于浏览器的同源策略,即a网站只能访问a网站的内容,......
  • elastic使用时报错Text fields are not optimised for operations that require per-d
    一、elasticsearch在做聚合查询的时候报错"root_cause":[{"type":"illegal_argument_exception","reason":"Textfieldsarenotoptimis......
  • springboot集成caffine本地缓存
    一、缓存算法1.FIFOFIFO(FirstinFirstout)先进先出。可以理解为是一种类似队列的算法实现算法:当一个查询请求命中了某个元素之后,便会将它放入到队列中,后续的命中元素也......
  • docker启动elasticsearch和kibana
    首先执行通过docker将以下镜像进行拉取:dockerpullelasticsearch:7.4.2用于存储和检索数据(版本可以自定义,两者版本需要统一)dockerpullkibana:7.4.2用于可视化检索数......
  • SpringBoot整合ueditor编辑器
    1.到ueditor编辑器官网下载jsp版(目前官网地址改为了GitHub)​​https://ueditor.baidu.com/website/download.html​​2.下载解压后复制到当前项目3.导入maven依赖<de......
  • Spring Boot---(25)SpringBoot使用AOP
    摘要:本文示例,是在一个简单的SpringBoot项目中,通过AOP技术,来实现对接口访问时的信息统计,和接口耗时统计。AOP是Spring提供的两个核心功能之一:IOC(控制反转),AOP(AspectOriented......