0

我正在尝试在 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 jettyStartorgradle jettyRunWar时,出现以下错误:

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

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

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

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

4

1 回答 1

0

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

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

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

于 2021-04-29T15:26:30.680 回答