【发布时间】: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 jettyStart 或gradle 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()存储库,您会更进一步。