使用 farmRun 任务时不应用 Gretty 配置
Gretty configuration doesn't applied when using farmRun task
我使用的 Gretty 示例来自:https://github.com/gretty-gradle-plugin/gretty-sample
在 master build.gradle 中,我只修改了存储库 URL(使用镜像 repo 由于代理):
build.gradle:
apply plugin: 'java'
buildscript {
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
//jcenter()
}
dependencies {
classpath 'org.gretty:gretty:+'
}
}
subprojects {
apply plugin: 'war'
apply plugin: 'org.gretty'
gretty {
scanInterval = 1 //Scan for changes every second
host = '0.0.0.0' //Enable network access from outside your local machine
httpPort = 8011
servletContainer = 'jetty7' //Use Jetty7 which is compatible with JDK6
managedClassReload = true //Activate spring-loaded class reloading
integrationTestTask = 'integrationTest'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
//jcenter()
}
}
apply plugin: 'org.gretty'
farm {
webapp ':customer'
webapp ':car'
}
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
您可以看到端口指定为:
httpPort = 8011
在子项目部分下。当我 运行 gradle
gradlew :farmRun
它报告:
17:38:42 INFO Jetty 9.2.26.v20180806 started and listening on port 8080
17:38:42 INFO customer runs at:
17:38:42 INFO http://localhost:8080/customer
17:38:42 INFO car runs at:
17:38:42 INFO http://localhost:8080/car
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':farmRun'.
> java.lang.Exception: Address already in use: bind
因此码头仍在尝试使用默认端口 8080。感谢您的任何提示。
:farmRun 未调用方法 subprojects。 gretty配置方法需要在根层或者直接是farm方法的一部分。
farm {
webapp ':customer'
webapp ':car'
gretty {
httpPort = 8012
servletContainer = 'jetty7' //Use Jetty7 which is compatible with JDK6
managedClassReload = true //Activate spring-loaded class reloading
}
}
我使用的 Gretty 示例来自:https://github.com/gretty-gradle-plugin/gretty-sample 在 master build.gradle 中,我只修改了存储库 URL(使用镜像 repo 由于代理):
build.gradle:
apply plugin: 'java'
buildscript {
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
//jcenter()
}
dependencies {
classpath 'org.gretty:gretty:+'
}
}
subprojects {
apply plugin: 'war'
apply plugin: 'org.gretty'
gretty {
scanInterval = 1 //Scan for changes every second
host = '0.0.0.0' //Enable network access from outside your local machine
httpPort = 8011
servletContainer = 'jetty7' //Use Jetty7 which is compatible with JDK6
managedClassReload = true //Activate spring-loaded class reloading
integrationTestTask = 'integrationTest'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
//jcenter()
}
}
apply plugin: 'org.gretty'
farm {
webapp ':customer'
webapp ':car'
}
repositories {
maven {
//url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'
url 'http://10.0.0.1:7003/nexus/content/groups/public/'
}
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
您可以看到端口指定为:
httpPort = 8011
在子项目部分下。当我 运行 gradle
gradlew :farmRun
它报告:
17:38:42 INFO Jetty 9.2.26.v20180806 started and listening on port 8080
17:38:42 INFO customer runs at:
17:38:42 INFO http://localhost:8080/customer
17:38:42 INFO car runs at:
17:38:42 INFO http://localhost:8080/car
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':farmRun'.
> java.lang.Exception: Address already in use: bind
因此码头仍在尝试使用默认端口 8080。感谢您的任何提示。
:farmRun 未调用方法 subprojects。 gretty配置方法需要在根层或者直接是farm方法的一部分。
farm {
webapp ':customer'
webapp ':car'
gretty {
httpPort = 8012
servletContainer = 'jetty7' //Use Jetty7 which is compatible with JDK6
managedClassReload = true //Activate spring-loaded class reloading
}
}