启动 Eureka 服务器的问题
Problems starting up Eureka Server
我正在尝试使用 Eureka 服务器和多个客户端设置 Zuul 网关。
到目前为止,我已经毫无问题地创建了网关和初始客户端,但由于某种原因,我在尝试启动注册表时一直遇到错误。
据我所知,问题与加载配置有关,根本原因是找不到 class com/sun/jersey/core/util/FeaturesAndProperties
。
我已经尝试明确定义 Jersey 组件,但无论我如何设置 pom(spring 导入之前的球衣,导入之后的球衣,不同的版本)我都会遇到同样的问题。
我也尝试了不同的发布序列,基于此页面 http://projects.spring.io/spring-cloud/ 并阅读了不同的依赖项。
我也尝试按照此处说明的指南进行操作http://www.baeldung.com/spring-cloud-netflix-eureka(我知道版本不同,我已将值调整为其他几个发布序列)
此时,球衣进口出现在 Maen 依赖项部分,pom.xml 如下所示。 (见截图)
我有点困惑,为什么我不能把它送到 运行。任何帮助将不胜感激,或指向包含更多详细信息的指南。
值得一提的是,我的application.yml是从我的读数中推导出来的,我得到了同样的错误,空白application.yml(或application.properties,我已经删除了)
存储库位于 https://github.com/JoSSte/MyEurekaRegistry
这是控制台中定义的错误行:
2018-01-07 13:05:59.334 ERROR 5708 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter :
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jerseyFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'jerseyFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyApplication' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.core.Application]: Factory method 'jerseyApplication' threw exception; nested exception is java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
MyRegistryApplication.java
package com.example.backend;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class MyRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(MyRegistryApplication.class, args);
}
}
application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>MyRegistry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyRegistry</name>
<description>My Gateway</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
编辑#1:
基于这个问题,How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds我决定列出我的依赖项(mvn dependency:list | grep jersey
)并查看我的依赖项中是否存在冲突的 Jersey 版本:
[INFO] com.sun.jersey:jersey-core:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-server:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-servlet:jar:1.19.1:compile
[INFO] com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:runtime
[INFO] com.sun.jersey:jersey-client:jar:1.19.1:runtime
如该列表所示,我有相同版本的 Jersey。除此之外,我的依赖项中没有 jax-rs,也没有任何 glassfish
继续阅读并发现大量对 Tomcat 类路径的引用,我决定尝试 运行 不同环境中的代码。
我启动了一个 Ubuntu 虚拟机,下载了 Spring 工具套件并将 the repository 克隆到其中。我 运行 这个项目,它毫不费力地启动了。
我现在已经卸载了我 PC 上的所有 Glassfish 服务器、Tomcat 服务器、JDKs 和 JRE,我正在重新安装特定的 JDK 并继续通过我的环境变量来确保我的类路径是 "clean",这有望解决问题。
浏览我的本地 Maven 存储库 (C:\Users\username\.m2\repository
) 并删除所有与 glassfish 和 jersey 相关的文件夹(IDE 关闭),然后启动 IDE, 运行ning maven update (alt+F5) 成功了。
如果我没记错的话,Spring Cloud Camden
必须这样做。我不知道最近的版本是否修复了这个问题。
你能在 Eureka
服务器上试试这个吗:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-core</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
我正在尝试使用 Eureka 服务器和多个客户端设置 Zuul 网关。
到目前为止,我已经毫无问题地创建了网关和初始客户端,但由于某种原因,我在尝试启动注册表时一直遇到错误。
据我所知,问题与加载配置有关,根本原因是找不到 class com/sun/jersey/core/util/FeaturesAndProperties
。
我已经尝试明确定义 Jersey 组件,但无论我如何设置 pom(spring 导入之前的球衣,导入之后的球衣,不同的版本)我都会遇到同样的问题。
我也尝试了不同的发布序列,基于此页面 http://projects.spring.io/spring-cloud/ 并阅读了不同的依赖项。
我也尝试按照此处说明的指南进行操作http://www.baeldung.com/spring-cloud-netflix-eureka(我知道版本不同,我已将值调整为其他几个发布序列)
此时,球衣进口出现在 Maen 依赖项部分,pom.xml 如下所示。 (见截图)
我有点困惑,为什么我不能把它送到 运行。任何帮助将不胜感激,或指向包含更多详细信息的指南。
值得一提的是,我的application.yml是从我的读数中推导出来的,我得到了同样的错误,空白application.yml(或application.properties,我已经删除了)
存储库位于 https://github.com/JoSSte/MyEurekaRegistry
这是控制台中定义的错误行:
2018-01-07 13:05:59.334 ERROR 5708 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter :
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jerseyFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'jerseyFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyApplication' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.core.Application]: Factory method 'jerseyApplication' threw exception; nested exception is java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
MyRegistryApplication.java
package com.example.backend;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class MyRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(MyRegistryApplication.class, args);
}
}
application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>MyRegistry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyRegistry</name>
<description>My Gateway</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
编辑#1:
基于这个问题,How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds我决定列出我的依赖项(mvn dependency:list | grep jersey
)并查看我的依赖项中是否存在冲突的 Jersey 版本:
[INFO] com.sun.jersey:jersey-core:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-server:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-servlet:jar:1.19.1:compile
[INFO] com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:runtime
[INFO] com.sun.jersey:jersey-client:jar:1.19.1:runtime
如该列表所示,我有相同版本的 Jersey。除此之外,我的依赖项中没有 jax-rs,也没有任何 glassfish
继续阅读并发现大量对 Tomcat 类路径的引用,我决定尝试 运行 不同环境中的代码。
我启动了一个 Ubuntu 虚拟机,下载了 Spring 工具套件并将 the repository 克隆到其中。我 运行 这个项目,它毫不费力地启动了。
我现在已经卸载了我 PC 上的所有 Glassfish 服务器、Tomcat 服务器、JDKs 和 JRE,我正在重新安装特定的 JDK 并继续通过我的环境变量来确保我的类路径是 "clean",这有望解决问题。
浏览我的本地 Maven 存储库 (C:\Users\username\.m2\repository
) 并删除所有与 glassfish 和 jersey 相关的文件夹(IDE 关闭),然后启动 IDE, 运行ning maven update (alt+F5) 成功了。
如果我没记错的话,Spring Cloud Camden
必须这样做。我不知道最近的版本是否修复了这个问题。
你能在 Eureka
服务器上试试这个吗:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-core</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>