码迷,mamicode.com
首页 > 编程语言 > 详细

SpringCloud学习第四章-Eureka创建

时间:2019-08-25 17:43:31      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:snap   desc   end   boot   dep   autoconf   auto   mod   static   

注:因为有了父项目,所以不需要引入boot的jar,项目都是maven构建

1、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">
    <parent>
        <artifactId>spring-cloud</artifactId>
        <groupId>org.hxm</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>


    <groupId>org.hxm</groupId>
    <artifactId>spring-eureka</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>



    <name>eureka-server</name>
    <description>Demo project for Spring Boot</description>


    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

</project>

2、application.yml文件

server:
port: 8761 #eureka 服务端口
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false #是否将自己注册到Eureka Server,默认为true
fetch-registry: false #是否从Eureka Server获取注册信息,默认为true
spring:
application:
name: eureka-server

3、Application.java(启动类)

package org.hxm.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

/**
 * @author : Aaron
 * create at:  2019-08-24  13:27
 * @description: eureka application
 */
@SpringBootApplication
@EnableEurekaServer
public class EurekaApp {
    public static void main(String[] args) {
        SpringApplication.run(EurekaApp.class,args);
    }
}

 

SpringCloud学习第四章-Eureka创建

标签:snap   desc   end   boot   dep   autoconf   auto   mod   static   

原文地址:https://www.cnblogs.com/JavaHxm/p/11408464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!