J.Olufsen
J.Olufsen

Reputation: 13915

Spring Boot - Error creating bean with name 'dataSource' defined in class path resource

I have Spring Boot web application. It's centered around RESTful approach. All configuration seems in place but for some reason MainController fails to handle request. It results in 404 error. How to fix it?

@Controller
public class MainController {

    @Autowired
    ParserService parserService;

    @RequestMapping(value="/", method= RequestMethod.GET)
    public @ResponseBody String displayStartPage(){
        return "{hello}";
    }
}

Application

@Configuration
@ComponentScan(basePackages = "")
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer{
        public static void main(final String[] args) {
            SpringApplication.run(Application.class, args);
        }

        @Override
        protected final SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
}

ParserController

@RestController
public class ParserController {

    @Autowired
    private ParserService parserService;

    @Autowired
    private RecordDao recordDao;

 private static final Logger LOG = Logger.getLogger(ParserController.class);

    @RequestMapping(value="/upload", method= RequestMethod.POST)
    public @ResponseBody String fileUploadPage(
   }
}

UPDATE

Seems like MySQL cannot be initialized by Spring....

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; 

nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; 

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Instantiation of bean failed; 

nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource()] threw exception; 

nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.

UPDATE2

application.properties

    # Database 
    spring.datasource.driverClassName = com.mysql.jdbc.Driver
    spring.datasource.url = jdbc:mysql://localhost:3306/logparser
    spring.datasource.username = root
    spring.datasource.password = root
    
    spring.jpa.database = MYSQL
    spring.jpa.show-sql = true
    
    # Hibernate
    hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate.show_sql: true
    hibernate.hbm2ddl.auto: update
    entitymanager.packagesToScan: /

UPDATE4

Seems lite controllers not responding eventhough @RequestMapping are set. Why might it be?

PS. It occurs when I run Maven's lifecycle test. When running in degub mode in IntelliJ there is no error outputted.

UPDATE5

Also I use this DAO as explained in tutorial....

public interface RecordDao extends CrudRepository<Record, Long> {
}

http://blog.netgloo.com/2014/10/27/using-mysql-in-spring-boot-via-spring-data-jpa-and-hibernate/

UPDATE6

I did changed my application properties. And tried every single combination but it refuses to work. ;(

Maven output:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running IntegrationTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.365 sec <<< FAILURE! - in IntegrationTest
saveParsedRecordsToDatabase(IntegrationTest)  Time elapsed: 2.01 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
    at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:101)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:331)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:213)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:290)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:292)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource()] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.

Upvotes: 137

Views: 946894

Answers (30)

Matheus cad
Matheus cad

Reputation: 1

I hope this can help someone in the future. The solution that worked for me was adding IntelliJ as an 'exception' in Windows Defender. It seems that Windows Defender was blocking my connection to the database, which was causing the same error. I'm not entirely sure why, but this worked. But this link might help in some way https://intellij-support.jetbrains.com/hc/en-us/articles/360006298560-Antivirus-Impact-on-Build-Speed.

Upvotes: 0

Lahiru Karunaratne
Lahiru Karunaratne

Reputation: 2268

For me in the model class @Table(name="table_name_here") was missing. And adding this annotation fixed this error

Upvotes: 0

AzyCrw4282
AzyCrw4282

Reputation: 7744

If you have this issue in gradle, you need to remove the Spring data library and rebuild gradle. I had to remove the following dependency to solve the error

implementation('org.springframework.boot:spring-boot-starter-data-jpa')

Upvotes: 0

For me no need to update below @SpringBootApplication annotation as @SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

Just updated deprecated spring.datasource.platform=h2 into spring.sql.init.platform=h2 and it is working fine.

Upvotes: 0

Preet Govind
Preet Govind

Reputation: 71

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

writing the above line in application.properties , it worked for me in case psql db with spring boot 3.0.3

Upvotes: 7

Fazal Haroon
Fazal Haroon

Reputation: 1163

Spring Boot version 2+ has a minor change. All DDL(Data Definition Language) - Table Creations and data updates should be done in schema.sql

To resolve this issue just add this

spring.jpa.defer-datasource-initialization = true

to application.properties file.

or

spring:
  jpa:
    defer-datasource-initialization: true

Add the above if you using yml to your application.yml file.

For Example for H2 In Memory Configuration

spring.jpa.defer-datasource-initialization = true
spring.h2.console.enabled=true
spring.sql.init.platform=h2
spring.datasource.url=jdbc:h2:mem:todo
spring.datasource.username=sa
spring.datasource.password=

Sometimes I've got a SQL Syntax Error when executing the spring boot application because of forgetting the semicolon(;) at the end of CREATE TABLE and sometimes SYSDATE() and NOW() have problems using NOW() for the current date, so make sure to write the correct SQL syntax for DDL or DML

Upvotes: 3

Abishethvarman V
Abishethvarman V

Reputation: 127

In the current context(above JDK17 & above Springboot 2.7), this issue commonly occurred. There are reasons for this connectivity issue. But common thing I have noticed when it occurred to me is clearly a connectivity issue related to databaseAutoConfiguration. The main database may be connected successfully with its properties and the test db doesnt. So need to build the project again to trigger the connection from the application.properties manually.

The error log of my particular scenario.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoConfigureTestDatabase.

So the solution that I'm proposing are

  1. Check the connector dependencies
  2. Check the application properties and the input credentials.
  3. Make sure the build the project by triggering the maven or gradle manually.
  4. Don't trust the autoconfiguration part and investigate it deeply.

Upvotes: 2

Kem Andrew
Kem Andrew

Reputation: 36

make sure you add all the dependencies in your pom.xml

 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</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-quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

Upvotes: 0

Lova Chittumuri
Lova Chittumuri

Reputation: 3303

Please add the below dependency to get rid of this.

            <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <scope>runtime</scope>
            </dependency>

Upvotes: 0

Silver Sky
Silver Sky

Reputation: 427

In my case, I had inserted a record in a table in data.sql, but that table's name was incorrect in schema.sql, where I had created that table.

Upvotes: 1

franklin forson
franklin forson

Reputation: 23

To resolve this issue give the primary key column value @NotNull not NULL annotation and it would work.

Upvotes: 0

Fares Naoui
Fares Naoui

Reputation: 37

This is my application.properties file:

spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.defer-datasource-initialization=true
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false

I'm using IntelliJ community edition with DB Browser Plugin

It works for me...

Upvotes: 0

Silas Mokone
Silas Mokone

Reputation: 11

using h2 and you need to add data.sql just make sure you add

spring.jpa.defer-datasource-initialization=true

on the application.properties.

Upvotes: 1

MonirRouissi
MonirRouissi

Reputation: 631

If you are using mysql you need 2 dependencies

1

. <dependency>          
<groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>        </dependency>

    
 <dependency> 
        <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>   </dependency>

If you are using potgress you only need :

1.

<dependency>        
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>              
      <scope>runtime</scope>
            </dependency>

Upvotes: 0

Jason Warner
Jason Warner

Reputation: 2723

Looks like the initial problem is with the auto-config.

If you don't need the datasource, simply remove it from the auto-config process:

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

Edit: If using @SpringBootApplication in your main class:

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

Upvotes: 212

M. Muhammadsodiq
M. Muhammadsodiq

Reputation: 135

Seems you are having a problem with datasource. If you don't need the datasource, simply disable it using

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
 

Just put this in your application.properties

Upvotes: 2

Rahul Kumar
Rahul Kumar

Reputation: 1

I have not used h2 configuration in pom file.I have added it and this problem was solved.

<dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

Upvotes: -1

Babi B
Babi B

Reputation: 303

I am working with spring boot 2.6.0 I tried several answers and they were not enough. One temporal solution I found was this

@SpringBootApplication(exclude = SqlInitializationAutoConfiguration.class)

Although it lets the server run and the h2-console appear I could not connect to my data.sql file. This was the error I got

Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149

This is the solution I found (Some have already been)Add these lines to the application.properties file

spring.jpa.show-sql=true
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
spring.jpa.defer-datasource-initialization=true

Save an re-run the server then try to access the db on the browser again from the h2-console

By default, data.sql scripts are now run before Hibernate is initialized. This aligns the behavior of basic script-based initialization with that of Flyway and Liquibase. If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true.

spring.jpa.defer-datasource-initialization=true solves the issue

Upvotes: 13

Athar Karim
Athar Karim

Reputation: 11

By default, with the latest version of Spring Boot, the load of data.sql is done before the tables are created. So use - spring.jpa.defer-datasource-initialization=true

Example -

**In application.properties :- **
spring.jpa.show-sql=true
spring.datasource.url=jdbc:h2:mem:testdb
spring.h2.console.enabled=true
spring.jpa.defer-datasource-initialization=true

Thanks Athar Karim

Upvotes: 1

Kartik ganiga
Kartik ganiga

Reputation: 390

Created database in MySQL

create database springboot2;

application.properties

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/springboot2
spring.datasource.username = root
spring.datasource.password = root
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port=9192

pom.xml

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </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>

main class

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

model class

package com.First.Try.springboot.entity;
    
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor 
@NoArgsConstructor
@Entity
@Table(name="PRODUCT_TBL1")
public class Product {
    @Id
    @GeneratedValue
    private int id;
    private String name;
    private int quantity;
    private double price;
    ....
    ....
    ....
 }

Upvotes: 0

Isuru Ranaweera
Isuru Ranaweera

Reputation: 102

Not directly related to the original question but this will be useful for someone. This error occurred to me with a simple two project structure. One project was handling some database operations with spring JDBC (say A) and the other did not have any JDBC operations at all(say B). But still, this error appeared while I was starting service B. Saying the datasource should be initialized properly.

As I figured out I had added this dependency to the parent pom of the two modules

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

This caused spring to initialize the JDBC dependencies for project B too. So, I moved it to project A's pom, everything was fine.

Hope this would help someone

Upvotes: 2

Gaurav Anand
Gaurav Anand

Reputation: 133

I was getting the same error, found out it was due to some of the dependencies missing in my pom.xml like that of Spring JPA, Hibernate, Mysql or maybe Jackson. So make sure that dependencies are not missing in your pom.xml and check their version compatibility.

<!-- Jpa and hibernate -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.2.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.0.3.Final</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

Upvotes: 8

Guchelkaben
Guchelkaben

Reputation: 1275

I solved my problem with the change of the parent Spring Boot Dependency.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.0.RELEASE</version>
</parent>

to

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.6.RELEASE</version>
</parent>

For more Information, take a look at the release notes: Spring Boot 2.1.0 Release Notes

Upvotes: 0

El Morabet Kamal
El Morabet Kamal

Reputation: 21

I was facing the same problem for several days, and finally the issue isn't with the code, the problem commes from maven, you must delete all the files that he downloaded from your hard drive "C:\Users\username.m2\repository", and do another update maven for your project, that will fix your problem.

Upvotes: 1

Kumar Abhishek
Kumar Abhishek

Reputation: 3124

This problem comes while you are running Test. Add dependency

testCompile group: 'com.h2database', name: 'h2', version: '1.4.197' 

Add folder resources under test source add file bootstrap.yml and provide content.

spring:
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:h2:mem:TEST
    driver-class-name: org.h2.Driver
    username: username
    password: password
    hikari:
      idle-timeout: 10000

this will setup your data source.

Upvotes: 5

tyrantqiao
tyrantqiao

Reputation: 339

Give you something different, when you encounter this kind of error, cannot create bean datasource in a test case.

It might be caused by some reasons:

  1. No datasource, you will need to create your datasource, h2 in-memory datasource or whatever, or you can choose the way like exclude={datasource··}.
  2. You have your datasource, like MySQL, but it still not work. It was caused by class AutoConfigureTestDatabase, It will choose a datasource for you which may cause ambiguity.

Solution: add @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) to avoid replace the default datasource.

Upvotes: 0

Alexander P.
Alexander P.

Reputation: 51

Check that you have database dependency at runtime group at build.gradle

runtime group: 'com.h2database', name: 'h2', version: '1.4.194'

or change scope from test to runtime if you use Maven

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.4.194</version>
    <scope>runtime</scope>
</dependency>

Upvotes: 3

ram kumar
ram kumar

Reputation: 11

In my case I just ignored the following in application.properties file:

# Hibernate

#spring.jpa.hibernate.ddl-auto=update

It works for me....

Upvotes: 1

janakiram pulipati
janakiram pulipati

Reputation: 29

If you're using application.properties in spring boot app, then just put the below line into application.properties and it should work:
spring.datasource.url: jdbc:mysql://google/?cloudSqlInstance=&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=****&password=****

Upvotes: 2

Mahesh Japkar
Mahesh Japkar

Reputation: 11

I was facing this issue even after supplying all required datasource properties in application.properties. Then I realized that properties configuration class was not getting scanned by Spring boot because it was in different package hierarchy compared to my Spring boot Application.java and hence no properties were applied to datasource object. I changed the package name of my properties configuration class and it started working.

Upvotes: 1

Related Questions