Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-12-25 16:35:58.957 ERROR 8816 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor 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$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
Caused by: java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
你这oracle驱动没加载啊,
http://mvnrepository.com/artifact/oracle
要对应你的oracle版本,上面是maven仓库的信息(ojdbc)
下面是pom配置文件:<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.example.thymeleaf
thymeleaf
0.0.1-SNAPSHOT
jar
thymeleaf
Demo project for Spring Boot And Thymeleaf
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
<!-- lookup parent from repository -->
UTF-8
UTF-8
1.8
<!-- Spring Boot Web 依赖 -->
org.springframework.boot
spring-boot-starter-thymeleaf
<!-- Spring Boot Mybatis 依赖 -->
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.0.0
<!-- oracle -->
com.oracle
ojdbc6
${ojdbc6.version}
<!-- 支持 @ConfigurationProperties 注解 -->
org.springframework.boot
spring-boot-configuration-processor
true
junit
junit
test
<!-- tomcat 的支持. -->
org.springframework.boot
spring-boot-starter-tomcat
provided
org.apache.tomcat.embed
tomcat-embed-jasper
provided
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-data-jpa
com.oracle
ojdbc14
10.2.0.4.0
runtime
org.springframework.boot
spring-boot-maven-plugin
下面是application.properties:
server.port=8080
logging.file=E:/spring-boot-thymeleaf.log
logging.level.org.springframework.web=ERROR
logging.level.org.apache=ERROR
logging.level.org.springframework.boot.web=ERROR
#thymeleaf start
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
#thymeleaf end
#oracle配置
spring.jpa.database=oracle
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:DWC
spring.datasource.username=test
spring.datasource.password=test
#1
spring.jpa.hibernate.ddl-auto=update
#2
spring.jpa.show-sql=true
spring.jackson.serialization.indent-output=true
Cannot load driver class: oracle.jdbc.driver.OracleDriver
不能加载驱动 !!!
看着像 oracle ojdbc的版本不对,ojdbc6 配的是jdk6,换个版本试试,中央仓库应该没有资源,你要重新下载个,然后打到本地的maven仓库
Cannot load driver class: oracle.jdbc.driver.OracleDriver
报错信息确实说的是不能加载驱动,,题主检查下配置依赖了没,,
是不是没有引入mybatis包,
org.mybatis
mybatis
3.4.5
是不是没有引入mybatis包(https://img-ask.csdn.net/upload/201712/25/1514197787_415621.png)
我也碰到过,这个是因为你的配置文件中配置jpa的那几个属性后面有空格,在springboot的jpa配置中,jpa的那几个属性=后面是不能有空格的。。。