[英]How to run Jetty with Gradle
我有一個 Gradle 項目,我正在嘗試用它 Jetty 運行它。 我的build.gradle
文件如下所示。
構建.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 ) 插件。 在 build_6xw4u3prr68h02k136x2vqowd.run(/myproject/build.gradle:3) :幫助
歡迎使用 Gradle 3.2.1。
gradle jettyRun
失敗,聲明Plugin with id 'jetty' not found。
所以問題是,我如何運行這樣的項目? 請注意,這個項目不是我寫的,我只需要在我的本地機器上運行它。
我不是 Gradle 的專家,只是一個初學者,但我想我找到了可以幫助你的東西。 我也在閱讀有關將 jetty 與 gradle 一起使用的信息,因為我經常將它與 Maven 一起使用。
事實證明,Jetty 作為插件不再受支持,您可以在這里找到: https : //docs.gradle.org/current/userguide/jetty_plugin.html
相反,您應該為同一目的使用 gretty: https ://plugins.gradle.org/plugin/org.gretty
希望這是有幫助的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.