Работа над проектом Spring Boot, который использует Oracle в качестве базы данных для конфигурации pom. xml ниже. Когда в файл pom включена зависимость H2, приложение запускается. Приложение использует только базу данных Oracle и не использует базу данных H2. Когда закомментирована зависимость H2, экземпляр tomcat Spring Boot завершается со следующей ошибкой. Полное сообщение об ошибке появляется под фрагментом pom. Требуется ли Hikari H2 даже при использовании другой базы данных?
Failed to determine a suitable driver class
Вот как выглядит раздел базы данных моего pom. xml выглядит так:
<!-- database -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
</dependency>
Сообщение об ошибке, полученное при попытке запуска Tomcat:
Exception: org.springframework.beans.factory.BeanCreationException.
Message: Error creating bean with name 'servletEndpointRegistrar'
defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:
Factory method 'servletEndpointRegistrar' threw exception;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'healthEndpoint' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]:
Factory method 'healthEndpoint' threw exception; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration':
Bean instantiation via constructor failed; nested exception is
org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration$$EnhancerBySpringCGLIB$$14a3b789]:
Constructor threw exception; 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
РЕДАКТИРОВАТЬ: соответствующие разделы приложения. Yaml
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
platform: "oracle"
initialization-mode: "${SPRING_DATASOURCE_INITIALIZATION-MODE:never}"
# Hikari configurations (spring.datasource.hikari)
hikari:
autoCommit: false
driverClassName: oracle.jdbc.driver.OracleDriver
jdbcUrl: ${DB_URL}
username: ${DB_USER}
password: ${DB_PASSWORD}
maximumPoolSize: ${config.spring.datasource.max-active}
minimumIdle: ${config.spring.datasource.min-active}
jpa:
database-platform: org.hibernate.dialect.Oracle10gDialect
hibernate:
ddl-auto: "${config.spring.jpa.hibernate.ddl-auto}"
properties:
hibernate:
format_sql: "${config.spring.jpa.format_sql}"
show_sql: "${config.spring.jpa.show_sql}"
use_sql_comments: "${config.spring.jpa.use_sql_comments}"
# Reads SPRING_PROFILES_ACTIVE environment variable. If does not exist,
fallback to default profile
profiles:
active: "${SPRING_PROFILES_ACTIVE:default}"
# servlet configuration
servlet:
multipart:
enabled: true
file-size-threshold: 2MB
max-file-size: 200MB
max_request_size: 300MB
и
spring:
datasource:
max-active: "${SPRING_DATASOURCE_MAXACTIVE:10}"
min-active: "${SPRING_DATASOURCE_MINACTIVE:5}"
jpa:
format_sql: false
hibernate:
ddl-auto: "${SPRING_JPA_HIBERNATE_DDLAUTO:none}"
show_sql: false
use_sql_comments: false