Spring Boot无法从yml文件读取DB配置。

3

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

当我尝试检查数据源时,它总是连接到"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找不到适当的数据库配置?
1个回答

0

当我将依赖从runtime("com.h2database:h2")更改为compile("com.h2database:h2")时,数据源开始工作了。有人能解释一下发生了什么吗?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接