SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/G:/sharp/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/G:/sharp/repo/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.RELEASE) 2019-01-09 15:32:12.690 INFO 5044 --- [ main] c.sharp.forward.SharpServiceApplication : Starting SharpServiceApplication on hh-PC with PID 5044 (G:\worksheet\sharp-service\target\classes started by Administrator in G:\worksheet\sharp-service)
2019-01-09 15:32:12.696 INFO 5044 --- [ main] c.sharp.forward.SharpServiceApplication : No active profile set, falling back to default profiles: default
log4j:WARN No appenders could be found for logger (com.alibaba.dubbo.common.logger.LoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2019-01-09 15:32:14.095 INFO 5044 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-01-09 15:32:14.113 INFO 5044 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-09 15:32:14.113 INFO 5044 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.12
2019-01-09 15:32:14.121 INFO 5044 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\topbandSoft\java\jre1.8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/topbandSoft/java/jre1.8/bin/server;D:/topbandSoft/java/jre1.8/bin;D:/topbandSoft/java/jre1.8/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jre7;D:\topbandSoft\java\jdk1.8\bin;D:\topbandSoft\java\jdk1.8\jre\bin;D:\topbandSoft\git\Git\cmd;D:\topbandSoft\svn\bin;D:\topbandSoft\maven\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin;C:\Program Files\bin;D:\topbandSoft\zookeeper/bin;D:\topbandSoft\zookeeper/conf;D:\putty\;D:\topbandSoft\eclipse4.8\eclipse;;.]
2019-01-09 15:32:14.217 INFO 5044 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-09 15:32:14.218 INFO 5044 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1465 ms
2019-01-09 15:32:14.241 INFO 5044 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-01-09 15:32:14.245 INFO 5044 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-01-09 15:32:14.246 INFO 5044 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-01-09 15:32:14.246 INFO 5044 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'formContentFilter' to: [/*]
2019-01-09 15:32:14.246 INFO 5044 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-01-09 15:32:14.288 WARN 5044 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file [G:\worksheet\sharp-mapper\target\classes\com\sharp\forward\mapper\UserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2019-01-09 15:32:14.289 INFO 5044 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-01-09 15:32:14.372 INFO 5044 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-09 15:32:14.374 ERROR 5044 --- [ 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).

按照网上各种查找参考https://blog.csdn.net/yl123456654321/article/details/82912901

最终发现问题出在了没有将配置文件扫描进去,我把它排除了,我的pom.xml中资源的配置如下:

 <resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<!-- <exclude>*.properties</exclude> -->
<!-- <exclude>application-dev.properties</exclude> -->
</excludes>
<includes>
<include>**/*.yml</include>
<include>application.properties</include>
<include>application-${profile.active}.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>

问题出在上面注释掉的exclude的配置上,这里理解过滤不正确,我把它排除在外了,参考https://blog.csdn.net/u014756827/article/details/52510899

<include>与<exclude>是用来圈定和排除某一文件目录下的文件是否是工程资源的。如果<include>与<exclude>划定的范围存在冲突时,以<exclude>划定的范围为准。大多数情况下,人们使用<include>和<exclude>是为了配合<filtering>实现过滤特定文件的需要。例如,在一个工程中,src/main/resources目录下都是工程的资源文件,并不需要<include>和<exclude>再进行划定。但如果我们需要对且仅对其中的jdbc.properties和mail.properties两个文件进行过滤的话,则需要借助<include>和<exclude>进行如下的配置:

     <resources>
<!-- Filter jdbc.properties & mail.properties. NOTE: We don't filter applicationContext-infrastructure.xml,
let it go with spring's resource process mechanism. -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>jdbc.properties</include>
<include>mail.properties</include>
</includes>
</resource>
<!-- Include other files as resources files. -->
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>jdbc.properties</exclude>
<exclude>mail.properties</exclude>
</excludes>
</resource>
</resources>

其中第一段<resource>配置声明:在src/main/resources目录下,仅jdbc.properties和mail.properties两个文件是资源文件,然后,这两个文件需要被过滤。而第二段<resource>配置声明:同样在src/main/resources目录下,除jdbc.properties和mail.properties两个文件外的其他文件也是资源文件,但是它们不会被过滤。

注释掉以后,可以加载属性文件,就可以启动了

springboot启动不能加载数据库驱动Failed to determine a suitable driver class的更多相关文章

  1. springboot 启动时加载数据库数据到本地Map

    InitDataConfig.java import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Dict; impo ...

  2. JDBC:加载数据库驱动、连接数据库(详细讲解)

    加载数据库驱动: 1)由于Java是一个纯面向对象语言,任何事物在其中都必须抽象成类或者类对象,数据库也不例外,JDBC同样也把数据库抽象成面向对象的结构: 2)JDBC将整个数据库驱动器在底层抽象成 ...

  3. ThinkCMF项目部署出现无法加载数据库驱动解决方案

    最近有个TP项目刚从从本地部署到阿里云服务器上,出现了无法加载数据库驱动的错误,提示 :( 无法加载数据库驱动: Think\Db\Driver 这里分享一下出现该错误的解决步骤: 首先记得项目部署到 ...

  4. java 加载数据库驱动

    JDBC编程步骤见 JDBC编程步骤 JDBC编程的第一步是加载数据库驱动,使用Class类的forName()方法,Class.forName("com.mysql.jdbc.Driver ...

  5. JDBC 学习笔记(四)—— JDBC 加载数据库驱动,获取数据库连接

    1. 加载数据库驱动 通常来说,JDBC 使用 Class 类的 forName() 静态方法来加载驱动,需要输入数据库驱动代表的字符串. 例如: 加载 MySQL 驱动: Class.forName ...

  6. jdbc 加载数据库驱动如何破坏双亲委托模式

    导读      通过jdbc链接数据库,是每个学习Java web 方向的人必然一开始会写的代码,虽然现在各路框架都帮大家封装好了jdbc,但是研究一下jdbc链接的套路还是很意义     术语以及相 ...

  7. SpringBoot 启动失败 Failed to determine a suitable driver class 问题解决方案

    Description: Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no ...

  8. SpringBoot启动报错Failed to determine a suitable driver class

    SpringBoot启动报错如下 Error starting ApplicationContext. To display the conditions report re-run your app ...

  9. Springboot 抛出Failed to determine a suitable driver class异常原因

    SpringBoot项目,已经依赖了MySQL驱动,却还是无法启动,通过问题排除,如果是启动项目,那么pom值 <packaging>pom</packaging> Faile ...

随机推荐

  1. Python之字符

    关于字符的常用操作:(字符为不可变长度的类型,故不能“增”.“删”等改变长度的操作) 1.改:改变字符串中的某个值.但为浅改变: name = "Python3.5" print( ...

  2. JavaScript的发展史

    一.JavaScript发展历程 1. 诞生 ​ JavaScript因互联网而生,紧跟浏览器的发展而发展. ​ 1990年,欧洲核能研究所(CERN)科学家在互联网(Internet)基础上,发明了 ...

  3. gitlab的搭建与使用(一)

    yum install curl policycoreutils openssh-server openssh-clients postfix -y systemctl enable sshd sys ...

  4. SQL SERVER2005自动备份 2012.3.29

    要想在 SQL2005上进行数据库的自动备份必须把sql server的SQL Server Agent服务开启,否则是无法进行自动备份的 启动完成之后,用户可以直接在“管理”下面的“维护计划”选项来 ...

  5. Maven笔记一

    简介:什么是maven Maven是一个跨平台的项目管理工具,主要用于基于java平台的项目构建,依赖管理. 如图为项目构建的过程. 解决的项目的问题: 1.  如果有好几个项目,这好几个项目中,需要 ...

  6. 03.Scala编程实战

    Scala编程实战 1.    课程目标 1.1.  目标:使用Akka实现一个简易版的spark通信框架 2.    项目概述 2.1.   需求 Hivesql----------> sel ...

  7. AngularJS四大特征

    AngularJS四大特征 1.MVC模式 Angular遵循软件工程的MVC模式,并鼓励展现,数据,和逻辑组件之间的松耦合.通过依赖注入(dependency injection),Angular为 ...

  8. Django 学习 之 视图层(views)

    一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML文档,或者一张图片. . . 是任何 ...

  9. 设计模式课程 设计模式精讲 14-2 组合模式coding

    1 代码演练 1.1 代码演练1(组合模式1) 1.2 代码演练2(组合模式1之完善) 1 代码演练 1.1 代码演练1(组合模式1) 需求: 打印出木木网的课程结构, 我们用一个组建类作为接口,课程 ...

  10. 把PHP大牛记下来,方便以后关注

    本帖最后由 fish_study 于 2014-12-31 00:18 编辑 五四陈科学院博主54chen(陈臻),哥学社创始人,前人人网分布式存储nuclear研发人员,现关注erlang.hado ...