Supports concurrent access to database. Database can be accessed at any time via Gradle task.
Last active
October 27, 2018 17:08
-
-
Save alessandroscarlatti/6760b619e965943110355b4a7b053f39 to your computer and use it in GitHub Desktop.
H2 Database with H2 Console Gradle Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
datasource: | |
url: jdbc:h2:file:./build/datasource;AUTO_SERVER=true | |
username: sa | |
password: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations { | |
h2 | |
} | |
configurations.compile.extendsFrom(configurations.h2) | |
dependencies { | |
h2 group: 'com.h2database', name: 'h2', version: '1.4.197' | |
} | |
task h2Console(type: Exec) { | |
group = 'application' | |
description = "run the H2 web console for this application's database" | |
commandLine 'java', '-jar', configurations.h2.singleFile, | |
'-url', 'jdbc:h2:file:./build/datasource;AUTO_SERVER=true', | |
'-user', 'sa' | |
} | |
// or without a configuration: | |
task h2ConsoleWithoutConfiguration(type: Exec) { | |
group = 'application' | |
description = "run the H2 web console for this application's database" | |
def h2Jar = configurations.compile.files.findResult { it.name.startsWith("h2") ? it : null } | |
commandLine 'java', '-jar', h2Jar, | |
'-url', 'jdbc:h2:file:./build/datasource;AUTO_SERVER=true', | |
'-user', 'sa' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment