java - springboot应用程序编译错误

标签 java spring hibernate spring-boot

创建 springboot 项目后,我遇到了 springboot 问题。我填写了 application.properties 以访问数据库。然后我尝试用maven编译,遇到了这些错误。我没有成功。

##DataSource settings
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/BD_GESTION_OPERATION?createDatabaseIfNotExist=true&userSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=system
spring.datasoutce.password=
spring.datasource.driver-class-name=com.oracle.jdbc.Driver

##Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1

##Disabling spring basic security
security.basic.enabled=false

##Start up port
server.port=8082

##Specify DBMS
spring.jpa.database=ORACLE

##Show/Hide SQL queries
spring.jpa.show-sql=false

##Hibernate DDL Auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto=update

##Naming strategy
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy

##Dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle11gDialect

The errors are as follows:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': 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$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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: 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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

java.lang.IllegalStateException: Failed to load ApplicationContext

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': 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$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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: 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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

Caused by: java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': 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$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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver
Caused by: 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 java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.oracle.jdbc.Driver

最佳答案

在我看来,你忘记在 maven 中提供依赖项

<dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc</artifactId>
        <version>8</version>
        <scope>system</scope>
        <systemPath>d:/projects/ojdbc8.jar</systemPath>
    </dependency>

请注意,要使其正常工作,您需要下载 jar 文件。这是一个快速解释 https://www.mkyong.com/jdbc/connect-to-oracle-db-via-jdbc-driver-java/

注意我假设你错过了,但我没有查看你的 pom 文件

关于java - springboot应用程序编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58543580/

相关文章:

java - float 的二进制数字提升

java - 替换同一选项卡中的 fragment

java - 选择给定时间段内的唯一登录

java - 为什么 Hibernate 在更新对象之前先从数据库查询对象

java - 记录密码查询

java - "How to fix ' MFA身份验证数据库连接错误“

spring - 如何在子项目中使用带有 gradle 的 spring.io 平台 bom

java - Spring使用注解时出错

Spring mvc 3 - HTTPS 访问

java - SpringMVC、c3p0、hibernate、JPA 应用程序泄漏连接导致 Too Many Connections 错误