繁体   English   中英

Spring启动不会从yml文件中读取数据库配置

[英]Spring boot doesn't read DB configuration from yml 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

当我尝试检查datasorce时,无论如何它连接到“jdbc:h2:mem:testdb”:

@Component
public class AfterInit implements CommandLineRunner {

    @Autowired
    DataSource dataSource;

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

为什么spring boot无法找到合适的数据库配置?

当我将runtime("com.h2database:h2")依赖项runtime("com.h2database:h2")更改为compile("com.h2database:h2") Datasource开始工作。 谁能解释一下我发生了什么?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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