我有一个 Gradle 项目,我正在尝试用它运行它 Jetty。 我的build.gradle
文件如下所示。
build.gradle
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
[jettyRun, jettyRunWar]*.httpPort = 8080
[jettyRun, jettyRunWar]*.contextPath = ''
[jettyRun, jettyRunWar]*.daemon = true
[jettyRun, jettyRunWar, jettyStop]*.stopPort = 8081
[jettyRun, jettyRunWar, jettyStop]*.stopKey = 'stop'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
test {
java {
srcDirs = ['src/test/java']
}
}
}
dependencies {
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.14'
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.14'
compile 'com.google.guava:guava:14.0.1'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'org.eclipse.jetty:jetty-server:9.4.7.v20170914'
testCompile 'org.eclipse.jetty:jetty-webapp:9.4.7.v20170914'
}
我正在尝试从命令行运行这个项目,我正在使用的命令是:
./gradlew
应生成项目,并输出以下内容:Jetty 插件已被弃用,计划在 Gradle 4.0 中删除。考虑改用 Gretty (https://github.com/akhikhl/gretty( 插件。 at build_6xw4u3prr68h02k136x2vqowd.run(/myproject/build.gradle:3( :帮助
欢迎来到 Gradle 3.2.1。
gradle jettyRun
失败,找不到ID 为"jetty"的语句插件。
所以问题是,我如何运行这样的项目?请注意,我没有编写这个项目,我只需要在本地机器上运行它。
我不是 Gradle 的专家,只是一个初学者,但我想我找到了可以帮助你的东西。 我也在阅读有关将码头与 gradle 一起使用的信息,因为我经常在 Maven 中使用它。
事实证明,不再支持Jetty作为插件,您可以在此处找到:https://docs.gradle.org/current/userguide/jetty_plugin.html
相反,您应该将gretty用于相同的目的: https://plugins.gradle.org/plugin/org.gretty
希望这是有帮助的。