Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have already added ojdbc ddriver and included the dependency in pom, but I still get the error mentioned in the title. Please help.

Earlier I ran the application with a local postgres db. Now trying to connect to a remote oracle db, and encountered this problem. I am logged into the necessary firewalls. The appplication started and performed as exected with the postgresdb.

I get the following logs when trying to start my application now -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-06 12:08:51.786 ERROR 27236 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
    Property: driverclassname
    Value: oracle.jdbc.OracleDriver
    Origin: "driverClassName" from property source "source"
    Reason: Failed to load driver class oracle.jdbc.OracleDriver in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
Process finished with exit code 1

The pom file is as below

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
        <groupId>package</groupId>
    <artifactId>QualityScore</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>QualityScore</name>
    <description>Demo project in Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>12.2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Application.properties -

##Postgres settings
##spring.datasource.url=jdbc:postgresql:*****
##spring.datasource.username=*****
##spring.datasource.password=*****
##spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.show-sql=true
# Oracle settings
spring.datasource.url=jdbc:oracle:*****
spring.datasource.username=*****
spring.datasource.password=*****
spring.datasource.driver-class=oracle.jdbc.driver.OracleDriver
# HikariCP settings
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.maximum-pool-size=5
#spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
                You wrote comment on pom.xml  (I removed this stuff, but they should not matter, if required please request in comments) . Which one you commented ?
– Avijit Barua
                Mar 6, 2020 at 7:45
                <groupId>package</groupId> 	<artifactId>QualityScore</artifactId> 	<version>0.0.1-SNAPSHOT</version> 	<name>QualityScore</name> 	<description>Demo Projectin Spring Boot</description>
– Lohith Kumar
                Mar 6, 2020 at 8:25
#spring.datasource.url=jdbc:*****
#spring.datasource.username=****
#spring.tasource.password=*****
#spring.jpa.database-platform = *****
spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:oracle:****
spring.datasource.username=*****
spring.datasource.password=*****
#spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
Recipientlist=*****

but you don't have your driver-class-name set. should be:

#spring.datasource.url=jdbc:*****
#spring.datasource.username=****
#spring.tasource.password=*****
#spring.jpa.database-platform = *****
spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:oracle:****
spring.datasource.username=*****
spring.datasource.password=*****
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
Recipientlist=*****

Regards!

Hi, I added the property(...OracleDriver) as you mentioned, but I am still getting the same error. – Lohith Kumar Mar 9, 2020 at 5:06

In my controller test classes, this error occurred when running the tests. Even with the spring.datasource.driver-class-name property set.

To resolve this, we added the DataSouce attribute with the @MockBean annotation in the controller test classes:

 @MockBean
 private DataSource dataSource;

The test classes performed perfectly.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.