【发布时间】:2019-08-26 16:39:58
【问题描述】:
我希望我的 Spring Boot 应用程序使用我输入的示例数据在其他计算机上运行。目前,我可以退出 IDE 并重新启动应用程序,它工作正常,但是当我上传我的项目供同事下载时,他们没有任何可以访问的数据。如何实现可以上传项目的功能,让使用该应用程序的每个人都可以访问我之前输入的测试数据?
我在主文件夹中的 application.properties:
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url=jdbc:h2:~/spring-boot-h2-db;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.hibernate.ddl-auto=update
我的 build.gradle:
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'de.hsba.bi.traveldiary'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.3.0'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
runtime 'com.h2database:h2'
}
提前非常感谢!
【问题讨论】:
-
您是否也共享位于用户主页中的 h2 数据库文件 (~/spring-boot-h2-db)。这就是数据所在。也分享这个文件,让你的同事把它放到他们的用户主目录中。
标签: java spring hibernate spring-boot jpa