Spring boot not reading db configuration from yml file

I have this config file:

liquibase:
  enabled: true
  change-log: classpath:/db/changelog/db.changelog-master.yml
management:
  security:
      enabled: false
server:
  port: 8080
spring:
  datasource:
    driverClassName: org.h2.Driver
    url: jdbc:h2:file:./target/h2db/db/develop;DB_CLOSE_DELAY=-1
    username: sa
    password:
  h2:
    console:
        enabled: true

      

When I try to test datasorce it still connects to "jdbc: h2: mem: testdb":

@Component
public class AfterInit implements CommandLineRunner {

    @Autowired
    DataSource dataSource;

    @Override
    public void run(String... args) throws Exception {
        out.println(dataSource);
    }
}

      

Why can't spring boot find the correct database configuration?

+3


source to share


1 answer


When I changed the dependency from runtime("com.h2database:h2")

to compile("com.h2database:h2")

, the Datasource started working. Can someone explain to me what happened?



0


source







All Articles