springCloud入门(二)eureka分布式注册中心

来源:互联网 发布:最新课件制作软件 编辑:程序博客网 时间:2024/06/08 11:41

pom.xml

<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>springCloud</groupId>  <artifactId>eurekaServer</artifactId>  <version>1.0-SNAPSHOT</version>  <packaging>jar</packaging>  <name>eurekaServer</name>  <url>http://maven.apache.org</url>  <parent>    <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-parent</artifactId>    <version>Brixton.RELEASE</version>    <relativePath /> <!-- lookup parent from repository -->  </parent>  <properties>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  </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-actuator</artifactId>    </dependency>  </dependencies>  <build>    <plugins>      <plugin>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-maven-plugin</artifactId>      </plugin>    </plugins>  </build></project>

启动类

package com.xinxing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication@EnableEurekaServerpublic class EurekaServer {    public static void main(String[] args) {        SpringApplication.run(EurekaServer.class, args);    }}

配置文件 application.properties

server.port=8761eureka.instance.hostname=localhosteureka.client.registerWithEureka=falseeureka.client.fetchRegistry=falseeureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/spring.application.name=cloud-eureka-server

这里写图片描述

eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
不允许注册中心服务器自动注册,否则会报错

阅读全文
0 0
原创粉丝点击