注:因为有了父项目,所以不需要引入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获取注册信息,默认为truespring: 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); } }
原文地址:https://www.cnblogs.com/JavaHxm/p/11408464.html
时间: 2024-11-08 05:50:30