无法使用Gradle和Spring Boot加载驱动程序类:com.mysql.jdbc.Driver

前端之家收集整理的这篇文章主要介绍了无法使用Gradle和Spring Boot加载驱动程序类:com.mysql.jdbc.Driver前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我的问题如下.我正在学习如何使用JDBC,Gradle和Spring框架(我对这些主题不熟悉).我一直试图实现以下example与一个区别,MysqL数据库而不是Postgresql.

就像我在标题中指定的那样,我的应用程序以以下错误结束无法加载驱动程序类:com.MysqL.jdbc.Driver(帖子末尾的堆栈跟踪).

当然我在发布这个问题之前一直在谷歌搜索和阅读,我发现com.MysqL.jdbc.Driver应该在程序中使用loader加载,或者也可以使用Gradle构建脚本来完成.

我的问题如下:

>为什么作者示例在没有加载器的情况下工作(在构建脚本中的程序中)@H_301_10@>如果加载器是绝对必要的,你能简要解释一下如何实现它吗?

修改的build.gradle文件

buildscript { 
    repositories { 
        maven { url "http://repo.spring.io/libs-snapshot" } 
    } 
    dependencies { 
        classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6") 
        classpath 'MysqL:MysqL-connector-java:5.1.34'  
    } 
} 

apply plugin: "java" 
apply plugin: "spring-boot" 

buildDir = "out" 

jar { 
    baseName = "sb-jdbc" 
    version = "0.1" 
} 

repositories { 
    mavenCentral() 
    maven { url "http://repo.spring.io/libs-snapshot" } 
} 

dependencies { 
    def springBootVersion = '1.0.0.RC1'
    compile("org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion")
    compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
    compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
    compile("MysqL:MysqL-connector-java:5.1.34")

    testCompile("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
    testCompile("junit:junit:4.11")
} 

我的application.properties文件

spring.datasource.driverClassName=com.MysqL.jdbc.Driver
spring.datasource.url=jdbc:MysqL://localhost/:3306/******
spring.datasource.username=root
spring.datasource.password=******

# Specify the DBMS
spring.jpa.database = MysqL

# Show or not log for each sql query
spring.jpa.show-sql = true

# Hibernate settings are prefixed with spring.jpa.hibernate.*
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.dialect = org.hibernate.dialect.MysqL5Dialect
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy

堆栈跟踪(未完整):

2015-01-03 20:09:20.203  WARN 10298 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Injection of autowired dependencies Failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.jdbc.core.JdbcTemplate demo.UserRepository.jdbc; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies Failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.populateBean(AbstractAutowireCapablebeanfactory.java:1202)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:476)
    at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:298)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:193)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:762)
    at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
    at demo.WebBindGradleApplication.main(WebBindGradleApplication.java:14)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.jdbc.core.JdbcTemplate demo.UserRepository.jdbc; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies Failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:558)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 22 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies Failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.populateBean(AbstractAutowireCapablebeanfactory.java:1202)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:476)
    at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:298)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:193)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:371)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateUsingFactoryMethod(AbstractAutowireCapablebeanfactory.java:1111)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBeanInstance(AbstractAutowireCapablebeanfactory.java:1006)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:476)
    at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:298)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:193)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.findAutowireCandidates(DefaultListablebeanfactory.java:1127)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.doResolveDependency(DefaultListablebeanfactory.java:1051)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.resolveDependency(DefaultListablebeanfactory.java:949)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:530)
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:558)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 44 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:602)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateUsingFactoryMethod(AbstractAutowireCapablebeanfactory.java:1111)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBeanInstance(AbstractAutowireCapablebeanfactory.java:1006)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:476)
    at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:298)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:193)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.findAutowireCandidates(DefaultListablebeanfactory.java:1127)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.doResolveDependency(DefaultListablebeanfactory.java:1051)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.resolveDependency(DefaultListablebeanfactory.java:949)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:530)
    ... 46 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:591)
    ... 58 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.MysqL.jdbc.Driver
    at org.springframework.util.Assert.state(Assert.java:385)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:122)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:116)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 59 common frames omitted

2015-01-03 20:09:20.254  INFO 10298 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2015-01-03 20:09:20.308  INFO 10298 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application Failed to start with classpath: [jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-web-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-jdbc-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-tomcat-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jackson-databind-2.4.4.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/hibernate-validator-5.1.3.Final.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-core-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-web-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-webmvc-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-jdbc-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-jdbc-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-tx-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-autoconfigure-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-logging-1.2.0.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/snakeyaml-1.14.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-core-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-el-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-logging-juli-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-websocket-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jackson-annotations-2.4.0.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jackson-core-2.4.4.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/validation-api-1.1.0.Final.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jboss-logging-3.1.3.GA.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/classmate-1.0.0.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-aop-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-beans-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-context-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/spring-expression-4.1.3.RELEASE.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/tomcat-juli-8.0.15.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jcl-over-slf4j-1.7.7.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/jul-to-slf4j-1.7.7.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/log4j-over-slf4j-1.7.7.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/logback-classic-1.1.2.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/aopalliance-1.0.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/slf4j-api-1.7.7.jar!/,jar:file:/home/pucek/Documents/workspace-sts-3.6.3.RELEASE/WebBindGradle/build/libs/demo-0.0.1-SNAPSHOT.jar!/lib/logback-core-1.1.2.jar!/]
2015-01-03 20:09:20.308  INFO 10298 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug)


2015-01-03 20:09:20.310 ERROR 10298 --- [           main] o.s.boot.SpringApplication               : Application startup Failed

提前感谢您的任何建议,探索,共享示例等等!@H_301_10@干杯!

编辑#1

正如Kamoor先生所说,这可能是缺少本地* jar文件的问题.我怀疑Gradle会自动从存储库下载它,万一我不会手动添加它(我在STS上工作).在这里我们可以看到MysqL-connector-java jar就在那里.

我很抱歉这些屏幕拍摄,我只是不知道其他方式来表明我添加它(我不习惯Eclipse).

最佳答案
我通过反复试验解决了这个问题.它对我来说是删除驱动程序引用表单application.properties文件.所以我的application.properties文件看起来像这样,错误立即消失:

spring.datasource.url = jdbc:MysqL://localhost:3306/test
spring.datasource.username = root 
spring.datasource.password = fake
#spring.datasource.driver-class-name = com.MysqL.jdbc.Driver 
mybatis.config=mybatis-config.xml
mybatis.check-config-location=true

我认为这与您在嵌入式Tomcat中需要该驱动程序的概率有关,而与应用程序代码本身无关

原文链接:https://www.f2er.com/spring/432054.html

猜你在找的Spring相关文章