Java – spring H2 embedded database

See the English answer > does spring embedded database support different SQL conversations? 3

MODE=MysqL
DB_CLOSE_ON_EXIT=FALSE

But I don't know what to do

@Bean
public DataSource dataSource(){
    return
        (new EmbeddedDatabaseBuilder())
        .setType(EmbeddedDatabaseType.H2) //.H2 
        .addScript("classpath:db/H2.schema.sql")
        .addScript("classpath:db/H2.data.sql")
        .build();
}

Solution

Try this

@Bean
public DataSource dataSource(){
    return
        new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.H2)
        .setName("testDB;DB_CLOSE_ON_EXIT=FALSE;MODE=MysqL") 
        .addScript("classpath:db/H2.schema.sql")
        .addScript("classpath:db/H2.data.sql")
        .build();
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>