Spring 引导应用程序(eureka 客户端)抛出 ClassNotFoundException:javax.ws.rs.core.Response$StatusType
The Spring boot application(eureka client) is throwing ClassNotFoundException: javax.ws.rs.core.Response$StatusType
我正在尝试将我的 Spring 启动应用程序注册到 eureka 服务器。应用程序开始,但在运行时我得到
"java.lang.NoClassDefFoundError: javax/ws/rs/core/Response$StatusType
at com.sun.jersey.api.client.ClientResponse.<init>(ClientResponse.java:381) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:176) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.12.jar:1.4.12]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access0(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
Build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootGradleVersion}")
}}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka'
}
非常感谢任何帮助。
提前致谢!!
尝试添加此依赖项:
// https://mvnrepository.com/artifact/javax.ws.rs/jsr311-api
compile group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'
您可能缺少所有必需的 WS 依赖项。当您使用 Spring 启动时,这将是获取它们的最佳方式:
compile("org.springframework.boot:spring-boot-starter-web-services")
// or
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
根据您的 Spring Boot 版本,它可能被称为 spring-boot-starter-ws
。
P.S。我不确定你为什么要混合依赖样式。随便选一个,随处使用。
我正在尝试将我的 Spring 启动应用程序注册到 eureka 服务器。应用程序开始,但在运行时我得到
"java.lang.NoClassDefFoundError: javax/ws/rs/core/Response$StatusType
at com.sun.jersey.api.client.ClientResponse.<init>(ClientResponse.java:381) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:176) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.12.jar:1.4.12]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access0(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
Build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootGradleVersion}")
}}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka'
}
非常感谢任何帮助。
提前致谢!!
尝试添加此依赖项:
// https://mvnrepository.com/artifact/javax.ws.rs/jsr311-api
compile group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'
您可能缺少所有必需的 WS 依赖项。当您使用 Spring 启动时,这将是获取它们的最佳方式:
compile("org.springframework.boot:spring-boot-starter-web-services")
// or
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
根据您的 Spring Boot 版本,它可能被称为 spring-boot-starter-ws
。
P.S。我不确定你为什么要混合依赖样式。随便选一个,随处使用。