1 说明

  1. 全部配置基于1.8.0_111
  2. 当前SpringBoot使用2.0.5

2 创建项目

SpringBoot项目生成器中,输入GroupArtifact,如下配置:

3 pom.xml配置

pom.xml文件中,加入以下:

<properties>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

4 配置application.yml文件

修改application.propertiesapplication.yml文件,加入以下:

server:
port: 8888
spring:
application:
name: eurka-server
security:
user:
name: anxminise
password: 123456
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:${server.port}/eureka/

5 编辑SpringBootEurekaApplication.java文件

编辑SpringBootEurekaApplication.java,如下:

@EnableEurekaServer
@SpringBootApplication
public class SpringBootEurekaApplication { public static void main(String[] args) {
SpringApplication.run(SpringBootEurekaApplication.class, args);
} @EnableWebSecurity
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
super.configure(http);
}
}
}

6 启动eureka

执行以下命令,进行构建并启动:

./mvnw clean package -DskipTests #构建可直接运行的jar包
java -jar target/SpringBootEureka-0.0.1-SNAPSHOT.jar #启动jar包



SpringBoot2.x搭建Eureka的更多相关文章

  1. SpringBoot2.x搭建SpringBootAdmin2.x

    1 说明 全部配置基于1.8.0_111 当前SpringBoot使用2.0.5 SpringBootAdmin基于Eureka进行Client发现,Eureka搭建参见SpringBoot2.x搭建 ...

  2. SpringCloud搭建Eureka集群

    第一部分:搭建Eureka Server集群 Step1:新建工程,引入依赖 依赖文件pom.xml如下 <?xml version="1.0" encoding=" ...

  3. Spring Cloud 如何搭建eureka

    Eureka Server 的搭建 eureka 是 Spring Cloud 的注册中心,提供服务注册和服务发现的功能. 利用idea 快速创建一个eureka应用File - NewProject ...

  4. 阶段5 3.微服务项目【学成在线】_day09 课程预览 Eureka Feign_03-Eureka注册中心-搭建Eureka高可用环境

    1.3.2.2 高可用环境搭建 Eureka Server 高可用环境需要部署两个Eureka server,它们互相向对方注册.如果在本机启动两个Eureka需要 注意两个Eureka Server ...

  5. SpringCloud学习之搭建eureka集群,手把手教学,新手教程

    一.为什么需要集群 上一篇文章讲解了如何搭建单个节点的eureka,这篇讲解如何搭建eureka集群,这里的集群还是本地不同的端口执行三个eureka,因为条件不要允许,没有三台电脑,所以大家将就一下 ...

  6. 14 微服务电商【黑马乐优商城】:day02-springcloud(搭建Eureka注册中心)

    本项目的笔记和资料的Download,请点击这一句话自行获取. day01-springboot(理论篇) :day01-springboot(实践篇) day02-springcloud(理论篇一) ...

  7. Springboot搭建Eureka并设置Eureka登录账号密码

    Springboot搭建Eureka并设置Eureka登录账号密码 一.创建一个springboot项目 1.可以使用Spring Initializr,用浏览器打开http://start.spri ...

  8. Spring Cloud之服务注册中心搭建Eureka Server服务注册中⼼

    Spring Cloud并不与Spring MVC类似是一个开源框架,而是一组解决问题的规范(个人理解).解决哪些问题呢?如下: 1)服务管理:⾃动注册与发现.状态监管 2)服务负载均衡 3)熔断 4 ...

  9. 基于dns搭建eureka集群

    eureka集群方案: 1.通常我们部署的eureka节点多于两个,根据实际需求,只需要将相邻节点进行相互注册(eureka节点形成环状),就达到了高可用性集群,任何一个eureka节点挂掉不会受到影 ...

随机推荐

  1. hasura graphql-engine + plv8 集成

    hasura graphql-engine 是一款很不错的基于pg 的graphql 引擎,plv8 是pg 的一个扩展,我们可以使用js 编写 函数 ,触发器,而且对于es6 的语法也有比较完备的支 ...

  2. 安装-supervisor

    centos 7.xx 1.#yum install python-setuptools 2.#easy_install supervisor 3.# vim /etc/supervisord.con ...

  3. 2018的Java

    少用复制黏贴 程序员很多时候都习惯复制黏贴,这里复制一点,那里复制一点,拼拼凑凑的搞出了一段代码.这是一种常态,毕竟没有必要重复造轮子,在开发的时候,讲究的是效率,讲究速度,有时候也是不得不这样做.但 ...

  4. 2018-2019-2 网络对抗技术 20165318 Exp 8 Web基础

    2018-2019-2 网络对抗技术 20165318 Exp 8 Web基础 原理与实践说明 实践内容概述 基础问题回答 实践过程记录 1.Web前端:HTML 2.Web前端:javascipt ...

  5. suface 触控笔

    触控笔直接就可以书写,顶部橡皮擦可用. 但如果要使用笔上的按键(如单击启动OneNote),必须要用蓝牙进行配对.笔使用一节AAAA电池(九号电池)供电. 连接方法: 准备好surface触控笔,并确 ...

  6. linux_FHS初遇--良好清晰条理的文件存储习惯

    1. 建议根目录(/)所在分区理论上越小越好,原因一为保证性能,二为易恢复与操作. 2.建议应用程序安装软件不要与根目录放在同一个分区内 3. 建议根目录(/)下应该存在的子目录: /bin 放置在单 ...

  7. odoo13 searchpanel tree

    <record id="view_department_filter" model="ir.ui.view"> <field name=&qu ...

  8. Laravel jwt 多表验证隔离

    为什么要做隔离 当同一个laravel项目有多端(移动端.管理端......)都需要使用jwt做用户验证时,如果用户表有多个(一般都会有),就需要做token隔离,不然会发生移动端的token也能请求 ...

  9. N x N 的矩阵,顺时针旋转

    第一种方法: 先打印外圈,再打印内圈 public class RotateMatrix1 { public static void rotate(int[][] matrix) { ; ; ; ]. ...

  10. 『磁力块 bfs 分块』

    磁力块 Description 在一片广袤无垠的原野上,散落着N 块磁石.每个磁石的性质可以用一个五元组 (x,y,m,p,r)描述,其中x,y 表示其坐标,m 是磁石的质量,p 是磁力,r 是吸引半 ...