繁体   English   中英

Spring Boot,Spring Data JPA,CrudRepository,基于文件的只读数据库,打包在JAR中

[英]Spring Boot, Spring Data JPA, CrudRepository, file based read only database packaged in JAR

我使用Spring Boot,Spring Data JPA和基于h2文件的数据库编写了一个应用程序。 一切顺利,一切顺利...感谢Spring。

现在,我尝试在另一个基于只读h2文件的数据库中提供一些系统数据。 是否可以将我的“ system.db”打包到JAR中,并使用Spring Data JPA访问它?

如何配置我的“系统数据源”以及代码的结构……总是毫不费力?

我有:

1)my.package.app.Application

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {

    public static void main(final String[] args) {
        new SpringApplication(Application.class).run(args);
    }
}

2)my.package.app.repo我的存储库(CrudRepository)的根软件包

3)config / application.properties

spring.datasource.url: jdbc:h2:file:~/MyApp/data/default
spring.datasource.username: sa
spring.datasource.password: sa
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.hibernate.ddl-auto: validate

您找到解决方案了吗?

也许使用schema.sqldata.sql 如在该文档中描述将提供了一个解决这个。

暂无
暂无

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

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