java eureka_eureka-server 项目搭建

1.用eclipse 创建maven Project 项目如下图所示:

f02079b423d22375960364e1015f2411.png

d227f90029a60f12c2871fd1ee5bec20.png

点击下一步:

d6615cfbdb540d98dd68366391b10706.png

点击finish

打开 pom.xml 文件,如下图所示:

2154e6ea2b6100a945659625237ccb70.png

2. 添加需要得pom 文件

org.springframework.boot

spring-boot-starter-parent

1.5.4.RELEASE

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-web

org.springframework.cloud

spring-cloud-starter-eureka-server

org.springframework.cloud

spring-cloud-dependencies

Dalston.SR1

pom

import

3. 在resources 文件下面添加配置文件

文件结构如下图

4feb2e8d749688e0c0689b7ab1637eea.png

application.propertis 文件内容如下:

spring.application.name=eureka-server-wyz1

server.port=1002

eureka.instance.hostname=localhost

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

3.添加启动文件Application.java 具体内容如下图:

package com.wyz.springCloud;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer

@SpringBootApplication

public class Application {

public static void main(String[] args){

new SpringApplicationBuilder(Application.class).web(true).run(args);

}

}

4. 通过如下方式:启动程序,具体操作如图所示:

9bc01b9d5d14858581eb877da5ef6e64.png

点击运行后

1cd0bc0cfa712a5d0877102aec5d3338.png

出现如上图时候,说明成功。

在浏览器输入:http://localhost:1002/ 如下图所示:

bb48d20a4acc6ed86e8b4d704bf7afe8.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值