当前位置:   article > 正文

gradle 提示 : Plugin with id 'jetty' not found.

plugin with id 'jetty' not found.

在一个web项目中,用到了jetty,在用gradle构建项目时发现提示 Plugin with id 'jetty' not found.即找不到这个插件。

Groovy代码如下:

  1. apply plugin: 'java'
  2. apply plugin: 'war'
  3. apply plugin: 'jetty'
  4. repositories {
  5. mavenCentral()
  6. }
  7. dependencies {
  8. providedCompile 'javax.servlet:servlet-api:2.5',
  9. 'javax.servlet.jsp:jsp-api:2.1'
  10. runtime 'javax.servlet:jstl:1.1.2',
  11. 'taglibs:standard:1.1.2'
  12. }
提示如下
FAILURE: Build failed with an exception.

* Where:
Build file 'H:\gradleCode\test\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating root project 'test'.
> Plugin with id 'jetty' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option
to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

去官网看了下,发现了个帖子https://discuss.gradle.org/t/gradle2-still-cant-specify-jetty-version/5069

说的是在Gradle 1.x 中jetty不能指定特定的版本,可我这的提示是根本找不到这个插件,我就很迷。。。。

帖子有人说推荐第三方库gretty 我尝试了一下,成功了

如果你用的Gradle是2.1版本以上的,就这几行代码就可以了

  1. plugins {
  2. id "org.akhikhl.gretty" version "2.0.0"
  3. }

否则就要写多几行:

  1. buildscript {
  2. repositories {
  3. maven {
  4. url "https://plugins.gradle.org/m2/"
  5. }
  6. }
  7. dependencies {
  8. classpath "gradle.plugin.org.akhikhl.gretty:gretty:2.0.0"
  9. }
  10. }
  11. apply plugin: "org.akhikhl.gretty"

这是我的build.gradle:

  1. apply plugin: 'java'
  2. apply plugin: 'war'
  3. buildscript {
  4. repositories {
  5. maven {
  6. url "https://plugins.gradle.org/m2/"
  7. }
  8. }
  9. dependencies {
  10. classpath "gradle.plugin.org.akhikhl.gretty:gretty:2.0.0"
  11. }
  12. }
  13. apply plugin: "org.akhikhl.gretty"
  14. repositories {
  15. jcenter()
  16. }
  17. dependencies {
  18. providedCompile 'javax.servlet:servlet-api:2.5',
  19. 'javax.servlet.jsp:jsp-api:2.1'
  20. runtime 'javax.servlet:jstl:1.1.2',
  21. 'taglibs:standard:1.1.2'
  22. }

运行结果如下:

gradle build
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/288956
推荐阅读
相关标签
  

闽ICP备14008679号