【问题标题】:Gradle 6.5.1 gretty 3.0.3 unable to run jettyGradle 6.5.1 gretty 3.0.3 无法运行码头
【发布时间】:2021-01-30 15:39:35
【问题描述】:

我正在尝试在 Eclipse 上使用 jersey 构建我的第一个 REST API。这是我的build.gradle

plugins {
    //id "com.dsvdsv.gradle.plugin" version "1.5.1"
    //id 'org.gretty' version '2.1.0'
    id "org.gretty" version "3.0.3"
    //id 'com.bmuschko.tomcat'
    id 'eclipse-wtp'
    id 'war'
    //id 'jetty'
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'application'

}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
mainClassName = 'com.example.demo.DemoApplication'

repositories {
    mavenCentral()
    //jcenter()
}

dependencies {
    // https://mvnrepository.com/artifact/org.gretty/gretty-runner-tomcat85
    //compile group: 'org.gretty', name: 'gretty-runner-tomcat85', version: '2.2.0'

    implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.25.1'
    implementation 'org.glassfish.jersey.inject:jersey-hk2:2.26'
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    //implementation 'com.bmuschko:gradle-tomcat-plugin:2.5'
}

test {
    useJUnitPlatform()
}

当我使用gradle jettyStartgradle jettyRunWar 时,出现以下错误:

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务 ':jettyStart' 执行失败。

无法解析配置“:grettyRunnerJetty94”的所有文件。 找不到 org.gretty:gretty-runner-jetty94:3.0.3。 要求: 项目:

我也试过 gretty 2.1.0 版本,但是无法访问。 Gradle 版本是 6.5.1

【问题讨论】:

  • 如果您运行gradle jettyStart --info,您将获得更多信息。似乎较新的 gretty 版本不在 Maven 中心。如果您取消注释 jcenter() 存储库,您会更进一步。

标签: gradle jetty gretty


【解决方案1】:

正如@Knut Forkalsrud 提到的,较新的gretty 版本不在maven central 中,您需要将jcenter() 添加到存储库列表中:

repositories {
    jcenter()
    mavenCentral()
    // other repositories
}

附加说明:存储库的顺序也很重要(类似于 maven)。因此,请确保将 jcenter() 添加到存储库列表中的正确位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    相关资源
    最近更新 更多