海宝宝m
2017-12-25 08:48
采纳率: 100%
浏览 3.8k
已采纳

springboot整合jpa时报错

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

9条回答 默认 最新

  • Q544471255 2017-12-25 15:20
    已采纳

    java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver

    你这oracle驱动没加载啊,

    http://mvnrepository.com/artifact/oracle

    要对应你的oracle版本,上面是maven仓库的信息(ojdbc)

    点赞 评论
  • 海宝宝m 2017-12-25 08:48

    下面是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



    点赞 评论
  • 海宝宝m 2017-12-25 08:49

    下面是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

    点赞 评论
  • kun_hello 2017-12-25 08:56

    Cannot load driver class: oracle.jdbc.driver.OracleDriver
    不能加载驱动 !!!

    点赞 评论
  • 朱明明啊 2017-12-25 09:07

    看着像 oracle ojdbc的版本不对,ojdbc6 配的是jdk6,换个版本试试,中央仓库应该没有资源,你要重新下载个,然后打到本地的maven仓库

    点赞 评论
  • 鼠小 2017-12-25 09:17
     Cannot load driver class: oracle.jdbc.driver.OracleDriver
    

    报错信息确实说的是不能加载驱动,,题主检查下配置依赖了没,,

    点赞 评论
  • wilsonzq 2017-12-25 10:28

    是不是没有引入mybatis包,


    org.mybatis
    mybatis
    3.4.5

    点赞 评论
  • wilsonzq 2017-12-25 10:30
    点赞 评论
  • jared_he2017 2017-12-25 10:45

    我也碰到过,这个是因为你的配置文件中配置jpa的那几个属性后面有空格,在springboot的jpa配置中,jpa的那几个属性=后面是不能有空格的。。。

    点赞 评论

相关推荐 更多相似问题