-Eureka创建
Posted javahxm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了-Eureka创建相关的知识,希望对你有一定的参考价值。
注:因为有了父项目,所以不需要引入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);
以上是关于-Eureka创建的主要内容,如果未能解决你的问题,请参考以下文章
SpringCloud创建eureka server和eureka client
白话SpringCloud | 第二章:服务注册与发现(Eureka)-上
eclipse创建springcloud项目——创建项目父工程Eureka