简体   繁体   中英

Spring boot doesn't read 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 check datasorce it connects to "jdbc:h2:mem:testdb" anyway:

@Component
public class AfterInit implements CommandLineRunner {

    @Autowired
    DataSource dataSource;

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

Why spring boot can't find proper database config?

When I changed dependency from runtime("com.h2database:h2") to compile("com.h2database:h2") Datasource became work. Can anybody explain me what's happend?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM