Java SpringBoot、SpringDataJPA、Crudepository、打包在JAR中的基于文件的只读数据库
我使用SpringBoot、SpringDataJPA和基于h2文件的数据库编写了一个应用程序。一切都很好,毫不费力。。。谢谢春天 现在,我尝试在另一个基于h2文件的只读数据库中传递一些系统数据。是否可以将我的“system.db”打包到JAR中,并使用Spring数据JPA访问它 如何配置我的“系统数据源”以及如何构造我的代码。。。总是毫不费力 我有: 1) my.package.app.ApplicationJava SpringBoot、SpringDataJPA、Crudepository、打包在JAR中的基于文件的只读数据库,java,spring,spring-data,spring-boot,h2,Java,Spring,Spring Data,Spring Boot,H2,我使用SpringBoot、SpringDataJPA和基于h2文件的数据库编写了一个应用程序。一切都很好,毫不费力。。。谢谢春天 现在,我尝试在另一个基于h2文件的只读数据库中传递一些系统数据。是否可以将我的“system.db”打包到JAR中,并使用Spring数据JPA访问它 如何配置我的“系统数据源”以及如何构造我的代码。。。总是毫不费力 我有: 1) my.package.app.Application @Configuration @ComponentScan @EnableAuto
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(final String[] args) {
new SpringApplication(Application.class).run(args);
}
}
2) my.package.app.repo我的存储库的根包(crudepository)
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