这篇文章主要介绍了SpringCould多模块搭建Eureka服务器端口过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
这篇文章主要介绍了SpringCould多模块搭建Eureka服务器端口过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
1创建一个普通父maven
在pom修改为因为spring Could依赖spring boot所以首先在父mavenorg.springframework.bootspring-boot-starter-parent2.0.5.RELEASEUTF-8UTF-81.8Finchley.SR1引入依赖org.springframework.cloudspring-cloud-dependencies${spring-cloud.version}pomimportjunitjunit4.12test2.创建一个Eureka1000把在父项目中有的删掉,添加依赖
org.springframework.cloudspring-cloud-starter-netflix-eureka-serverorg.springframework.bootspring-boot-starter-web
3.在Eureka1000中创建resources并且写入Java文件
resources
application.yml
server: port: 1000 #端口号 eureka: instance: hostname: localhost client: registerWithEureka: false fetchRegistry: false serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
主配置类
package cn.jiedada; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); } }
运行出现