2017-05-14 45 views
1

我有這個配置文件:春天開機不讀陽明文件DB配置

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無法找到正確的數據庫配置?

回答

0

當我將依賴從runtime("com.h2database:h2")更改爲compile("com.h2database:h2")數據源成爲工作。 有人可以解釋我發生了什麼事嗎?