SpringCloud -- Eureka单机搭建


<?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>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.6.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.seata</groupId>
	<artifactId>Eureka</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>Eureka</name>
	<description>Demo project for Spring Boot</description>
 
	<properties>
		<java.version>1.8</java.version>
		<spring-cloud.version>Finchley.SR4</spring-cloud.version>
	</properties>
 
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-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>
package com.seata.eureka;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
 
@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
 
	public static void main(String[] args) {
		SpringApplication.run(EurekaApplication.class, args);
	}
 
}


spring:
  application:
    name: Eureka-7001
    
server:
  port: 7001
 
eureka:
  client: #客户端进行Eureka注册的配置
    service-url:
      defaultZone: http://localhost:7001/eureka
    register-with-eureka: false #当前微服务不注册到eureka中
    fetch-registry: false  #不通过eureka获取注册信息
  instance: #eureka实例定义
    hostname: Eureka-7001 #定义eureka实例所在的主机名称
    instance-id: Eureka-7001 #在信息列表时显示主机名称
    prefer-ip-address: true  #访问路径变为IP地址



启动后访问:localhost:7001

20190709121455874.png


















eureka

2020.11.18 21:30

https://www.meihaocloud.com.com/98.html , 欢迎转载,请在文章页标出原文连接 !


Copyright © 2020 千夕网 联系站长

粤公网安备 44030302001408号 粤ICP备19099833号-1