美文网首页
搭建Eureka服务端

搭建Eureka服务端

作者: CrazyCat_007 | 来源:发表于2019-01-28 09:18 被阅读0次

eureka-service配置

application.yml

application.yml

#eureka默认情况下,将自己作为客服端进行注册,因此需要禁用该行为

registerWithEureka: false  #表示是否将自己注册到Eureka Server上,默认为true

fetchRegistry: false  #表示是否从Eureka Server上获取注册信息,默认为true

pom.xml

pom.xml

在pom文件中,重点注意如下依赖:

1.

<parent>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-parent</artifactId>

        <version>2.0.2.RELEASE</version>

        <relativePath />

</parent>

若无此依赖,启动时报错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gsonBuilder' defined in class path resource [org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.class]:Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.gson.GsonBuilder]: Factory method 'gsonBuilder' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;

2.

<dependencyManagement>

        <dependencies>

            <dependency>

                <groupId>org.springframework.cloud</groupId>

                <artifactId>spring-cloud-dependencies</artifactId>

                <version>Finchley.RELEASE</version>

                <type>pom</type>

                <scope>import</scope>

            </dependency>

        </dependencies>

</dependencyManagement>

若无此处依赖,启动该spring-cloud-starter-netflix-eureka-server会报错:

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]

3.

<dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>

            <version>2.0.0.RELEASE</version>

</dependency>

该依赖用于配置eureka服务端。

DiscoveryServiceApplication.java

DiscoveryServiceApplication.java

访问localhost:8761

Eureka登录

相关文章

网友评论

      本文标题:搭建Eureka服务端

      本文链接:https://www.haomeiwen.com/subject/sovojqtx.html