本文介紹了如何用Gradle運營Jetty的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個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)插件。
在build_6xw4u3prr68h02k136x2vqowd.run(/myproject/build.gradle:3)
:幫助
歡迎使用Gradle 3.2.1。
gradle jettyRun
失敗,找不到ID為‘jetty’的語句插件。
所以問題是,我如何運行這樣的項目?請注意,此項目不是我編寫的,我只需要在我的本地計算機上運行它。
推薦答案
我不是Gradle方面的專家,只是初學者,但我想我找到了一些可以幫助您的東西。
我還讀到有關在Gradle中使用Jetty的內容,因為我經常在Maven中使用它。
原來,不再支持Jetty作為插件,您可以在這里找到:https://docs.gradle.org/current/userguide/jetty_plugin.html
相反,您應該使用Gretty實現相同的目的:
https://plugins.gradle.org/plugin/org.gretty
希望這對您有幫助。
這篇關于如何用Gradle運營Jetty的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,