springboot启动出现APPLICATION FAILED TO START

springboot启动错误:APPLICATION FAILED TO START

解决方式1:
在启动类@SpringBootApplication后面,添加括号,然后写exclude = {DataSourceAutoConfiguration.class},即可。

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

解决方式2:
在application.xml或application.yml中添加druid的配置数据,
如下图:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/db_student?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
    driver-class-name: com.mysql.cj.jdbc.Driver

    #阿里巴巴的数据库框架
    type: com.alibaba.druid.pool.DruidDataSource

    #Spring Boot默认是不注入这些属性值的,需要自己绑定
    #durid 数据源专有配置
    initialSize: 5
    minIdle: 5
    maxActice: 20
    maxWait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true

    #配置监控统计拦截的filters,stat:监控统计、log4j:日记记录、wall:防御sql注入
    #如果允许时报错  java.lang.ClassNotFoundExceptionn: org.apache.log4j.Priority
    #则导入 log4j 依赖即可,maven地址:https://mvnrepository.com/artifact/log4j/log4j
    filters: stat,wall,log4j
    maxPoolPreparedStatementPerConnectionSize: 20
    useGlobaDataSourcestat: true
    connectionProperties: druid.stat.meregeSql=true;druid.stat.slowSqlMillis=500
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值