私はh2
インメモリデータベースをテスト目的でのみ使用します。デフォルトのポートは8082
と思われます。これは私のテストがヒロクで失敗する原因になります。組み込みh2データベース用のポート番号を設定
このポート番号を変更します。どうやってやるの ?
は、このポートを指定し、私のローカルマシン(
$USER_HOME/.h2.server.properties
)上のファイルがあるようです:私はこれまで何をやったか。そのファイルをアプリケーションワークスペースの外に持っていることは非常に奇妙なことですが、私はそれを英雄でチェックすることはできません。 、
私は
application-test.properties
でport
(それは性質が、私は私のテストのために使用するファイル)、webPort
を設定しようとしましたが、それは私が異なる組み合わせserver.port
、 `spring.data.source.h2.webPort試してみました(動作しませんでした build.gradle等)
application-test.properties
spring.datasource.url=jdbc:h2:mem:tesdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE")
}
}
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test{
forkEvery = 1
testLogging {
showStandardStreams = true
}
}
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.8.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'1.5.8.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.44'
compile group: 'org.javassist', name: 'javassist', version:'3.18.0-GA'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version:'1.5.8.RELEASE'
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version:'2.0.14.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version:'1.5.8.RELEASE'
compile group: 'io.jsonwebtoken', name: 'jjwt', version:'0.7.0'
compile group: 'org.springframework.security', name: 'spring-security-cas', version:'4.2.3.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-acl', version:'4.2.3.RELEASE'
compile group: 'bsf', name: 'bsf', version:'2.4.0'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-batch', version:'1.5.8.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version:'1.5.8.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-ldap', version:'4.2.3.RELEASE'
compile group: 'javax.jdo', name: 'jdo-api', version:'3.0.1'
compile group: 'com.querydsl', name: 'querydsl-core', version:'4.1.4'
compile group: 'org.springframework', name: 'springloaded', version:'1.2.8.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest', version:'1.5.8.RELEASE'
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version:'1.0.6'
compile group: 'org.scala-lang', name: 'scala-library', version:'2.11.0'
compile group: 'commons-validator', name: 'commons-validator', version:'1.6'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jersey', version:'1.5.8.RELEASE'
compile group: 'org.modelmapper', name: 'modelmapper', version:'0.7.5'
compile(group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5.3') {
exclude(module: 'commons-logging')
}
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'1.5.8.RELEASE') {
exclude(module: 'commons-logging')
}
compile group: 'org.eclipse.jetty.aggregate', name: 'jetty-all', version:'9.2.13.v20150730'
compile group: 'com.h2database', name: 'h2', version:'1.4.196'
compile group: 'org.springframework.integration', name: 'spring-integration-test', version:'4.3.12.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-test', version:'4.2.3.RELEASE'
compile group: 'org.apache.hadoop', name: 'hadoop-core', version:'1.0.0'
compile group: 'com.sleepycat', name: 'je', version:'5.0.73'
compile group: 'commons-dbcp', name: 'commons-dbcp', version:'1.4'
compile group: 'org.springframework', name: 'spring-webmvc', version:'4.3.12.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-commons', version:'1.13.8.RELEASE'
compile group: 'org.springframework.hateoas', name: 'spring-hateoas', version:'0.23.0.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-rest-core', version:'2.6.8.RELEASE'
compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version:'1.2.0.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version:'4.3.12.RELEASE'
testCompile group: 'junit', name: 'junit', version:'4.11'
testCompile group: 'org.springframework', name: 'spring-test', version:'4.3.12.RELEASE'
}
JDBC-URLには、ソケットもポートも必要としない接続文字列を含めることができます。それはテスト目的のためにそれを完全にします。 jdbc-connection-urlの例を挙げてください。 –
どのようにh2サーバーを起動していますか?他のアプリケーションからデータベースに接続する必要がない場合は、なぜtcpサーバを起動していますか?残りのデータベース関連設定は何ですか? – Oleg
'8082'は、h2console webServerで使用されるポートです。スプリングブートはそれを使用しません。 Beanを起動するBeanを持っているか、どこかで 'Server.createWebServer'を使って自分で起動するBeanがあります。ポートを変更することはあなたを助けません、あなたはヒーロー上で1つのポートしか使用できません。 – Oleg