spring cloud 之eureka-server

来源:互联网 发布:福建公安便民网络 编辑:程序博客网 时间:2024/06/05 01:55

1.pom.xml

<?xml version="1.0"?><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  <modelVersion>4.0.0</modelVersion>  <parent>    <groupId>com.djl.springcloud</groupId>    <artifactId>spring-cloud-demo</artifactId>    <version>0.0.1-SNAPSHOT</version>  </parent>  <artifactId>eureka-server</artifactId>  <name>eureka-server</name>  <url>http://maven.apache.org</url>  <properties>       </properties>    <dependencies>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-eureka</artifactId>        </dependency>        <!--表示为web工程-->        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <!--暴露各种指标-->        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-actuator</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-eureka-server</artifactId>        </dependency>    </dependencies></project>

2./eureka-server/src/main/resources/application.properties

server.port=8761eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/eureka.client.registerWithEureka=falseeureka.client.fetchRegistry=false

3.main入口

package com.djl.springcloud.eureka.server;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@EnableEurekaServer@SpringBootApplicationpublic class ServerApplication {    public static void main(String[] args) {        new SpringApplicationBuilder(ServerApplication.class).web(true).run(args);    }}
4.启动成功日志

2017-07-29 21:53:33.958  INFO 11640 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 02017-07-29 21:53:33.962  INFO 11640 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application unknown with eureka with status UP2017-07-29 21:53:33.963  INFO 11640 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..2017-07-29 21:53:33.964  INFO 11640 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default2017-07-29 21:53:33.964  INFO 11640 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test2017-07-29 21:53:33.988  INFO 11640 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false2017-07-29 21:53:33.989  INFO 11640 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context2017-07-29 21:53:33.989  INFO 11640 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node2017-07-29 21:53:33.989  INFO 11640 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 12017-07-29 21:53:33.989  INFO 11640 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP2017-07-29 21:53:34.007  INFO 11640 --- [      Thread-10] e.s.EurekaServerInitializerConfiguration : Started Eureka Server2017-07-29 21:53:34.247  INFO 11640 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8761 (http)2017-07-29 21:53:34.250  INFO 11640 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 87612017-07-29 21:53:34.258  INFO 11640 --- [           main] c.d.s.eureka.server.ServerApplication    : Started ServerApplication in 23.088 seconds (JVM running for 24.651)2017-07-29 21:54:33.991  INFO 11640 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms2017-07-29 21:55:33.993  INFO 11640 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 1ms

5.访问 http://localhost:8761/



能看到上面的页面~成功 OK