1. 添加pom 依赖:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!-- 加密解密jar begin -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.14</version>
</dependency>
<!-- 加密解密jar end -->
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>

</dependencies>
</dependencyManagement>
</project>

2. 写启动类

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {

public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}

3. 配置:

server:
port: 8759
security:
user:
name: admin
password: ENC(8tNuxZqCsf0G0sxRS+cc6g==)
basic:
enabled: true
jasypt:
encryptor:
password: wp3Lcomaohuidongl4ym8ofoYAYA==
eureka:
instance:
hostname: test
server:
#enable-self-preservation: false
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://localhost:${server.port}/eureka

4. 加密解密main

public class SecretMain {
private static final Logger LOG = LoggerFactory.getLogger(SecretMain.class);

public static void main(String[] args) {

//第一种方式加�? admin
BasicTextEncryptor text1= new BasicTextEncryptor();
text1.setPassword("wp3Lcomaohuidongl4ym8ofoYAYA==");
String newPassword = text1.encrypt("admin");
LOG.info("newPassword={}",newPassword);

// //第一种方式解�? admin
// BasicTextEncryptor text2 = new BasicTextEncryptor();
// text2.setPassword("wp3Lcomaohuidongl4ym8ofoYAYA==");
// String oldPassword = text2.decrypt("MrmNu24HSDHHnNYMnosl2g==");
// LOG.info("oldPassword={}",oldPassword);
//
// LOG.info("--------------------------------------------");
// //第二种方式加密admin
// StandardPBEStringEncryptor standard = new StandardPBEStringEncryptor();
// standard.setPassword("wwwwp3Lcomaohuidongl4ym8ofoYAYAAA==");
// String standardNewPassword = standard.encrypt("admin12");
// LOG.info("standardNewPassword={}",standardNewPassword);
//
// //第二种方式解�?
// StandardPBEStringEncryptor oldStandard = new StandardPBEStringEncryptor();
// oldStandard.setPassword("wwwwp3Lcomaohuidongl4ym8ofoYAYAAA==");
// String old = oldStandard.decrypt("+yKjbX67r7BrfFRdtePcrQ==");
// LOG.info("old={}",old);
}

}

5. 多注册中心的配置

spring:
profiles:
active: eureka3
security:
user:
name: ENC(3WnMCLtpRE7IkTDsvYIUjQ==)
password: ENC(3WnMCLtpRE7IkTDsvYIUjQ==)
jasypt:
encryptor:
password: wp3Lcomaohuidongl4ym8ofoYAYA==
---
spring:
application:
name: ym-eureka-server
profiles: eureka1
server:
port: 8761
eureka:
instance:
hostname: ym-eureka-server1
client:
#registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://admin:admin@ym-eureka-server2:8762/eureka/,http://admin:admin@ym-eureka-server3:8763/eureka/
---
spring:
application:
name: ym-eureka-server
profiles: eureka2
server:
port: 8762
eureka:
instance:
hostname: ym-eureka-server2
client:
#registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://admin:admin@ym-eureka-server1:8761/eureka/,http://admin:admin@ym-eureka-server3:8763/eureka/
---
spring:
application:
name: ym-eureka-server
profiles: eureka3
server:
port: 8763
eureka:
instance:
hostname: ym-eureka-server3
client:
#registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://admin:admin@ym-eureka-server1:8761/eureka/,http://admin:admin@ym-eureka-server2:8762/eureka/

spring cloud: eureka搭建的更多相关文章

  1. spring cloud Eureka 服务注册发现与调用

    记录一下用spring cloud Eureka搭建服务注册与发现框架的过程. 为了创建spring项目方便,使用了STS. 一.Eureka注册中心 1.新建项目-Spring Starter Pr ...

  2. Spring Cloud Eureka Server集群Demo级搭建

    将上篇随笔Spring Cloud Eureka服务Demo级搭建进行改造,改造成一个在本机的伪集群 1.修改hosts文件(windows10 hosts文件位置:C:\Windows\System ...

  3. Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版!

    Spring Cloud 的注册中心可以由 Eureka.Consul.Zookeeper.ETCD 等来实现,这里推荐使用 Spring Cloud Eureka 来实现注册中心,它基于 Netfl ...

  4. Spring cloud Eureka 服务治理(搭建服务注册中心)

    服务之类是微服务架构中最为核心的基础模块,它主要用来实现各个微服务实例的自动化注册和发现. 1. 服务注册 在服务治理框架中,通常会构建一个注册中心,每个服务单元向注册中心登记自己提供的服务,将主机. ...

  5. spring cloud config搭建说明例子(二)-添加eureka

    添加注册eureka 服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</ ...

  6. Spring Cloud 如何搭建eureka

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

  7. 1 Spring Cloud Eureka服务治理

    注:此随笔为读书笔记.<Spring Cloud微服务实战> 什么是微服务? 微服务是将一个原本独立的系统拆分成若干个小型服务(一般按照功能模块拆分),这些小型服务都在各自独立的进程中运行 ...

  8. 笔记:Spring Cloud Eureka 服务治理

    Spring Cloud Eureka 是 Spring Cloud Netflix 微服务套件的一部分,基于 Netflix Eureka 做了二次封装,主要负责完成微服务架构中的服务治理功能,服务 ...

  9. Spring Cloud Eureka 常用配置详解,建议收藏!

    前几天,栈长分享了 <Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版!>,今天来分享下 Spring Cloud Eureka 常用的一些参数配置及说 ...

  10. Spring Cloud Eureka 你还在让它裸奔吗??

    前些天栈长在微信公众号Java技术栈分享了 Spring Cloud Eureka 最新版 实现注册中心的实战教程:Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版 ...

随机推荐

  1. Java Web Service 学习笔记

    一.服务端 1. 创建Java工程 2. 创建接口HostipalServiceInterface package ws_server; import javax.jws.WebMethod; imp ...

  2. golang cannot assign to

    问题: # command-line-arguments .\example.go:22: cannot assign to m.V.(BasicMessage).Length 想在函数中修改inte ...

  3. python 典型文件结构

    #/usr/bin/env/ python #(1) 起始行 "this is a test module" #(2) 模块文档(文档字符串) import sys import ...

  4. Sql Server Report Service 的部署问题

    近期在研究SSRS部署问题,因为以前也用到过SSRS报表,但当时开发的报表是有专门的集成系统的,不需要我自己去部署,所以对这一块的部署也不熟悉,我记得当时我是直接开发出一个SSRS 报表,然后会通过自 ...

  5. fckeditor 配置

    因为下载下来的压缩包里面有包含很多在我们使用时,用不到的,不删除也行.看个人喜好下面以PHP为例,进行程序瘦身 删除所有”_”开头的文件和文件夹   删除FCKeditor的目录下:   fckedi ...

  6. 【C#】string格式的日期转为DateTime类型及时间格式化处理方法

    日期格式:yyyyMMdd HH:mm:ss(注意此字符串的字母大小写很严格) yyyy:代表年份 MM: 代表月份 dd: 代表天 HH: 代表小时(24小时制) mm: 代表分钟 ss: 代表秒 ...

  7. linux shell 命令常用快捷键

    下面是一些shell的常用快捷键,快捷键玩熟悉了在一定程度上是可以提高工作效率滴… Ctrl + a 切换到命令行开始 Ctrl + e 切换到命令行末尾 Ctrl + l 清除屏幕内容 Ctrl + ...

  8. Leetcode 之Simplify Path @ python

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...

  9. 针对ROS5版本的配置导出和导入(迁移其他服务器)

    1.在老ROS,导出当前系统配置export compact RouterOS 5.12 新增功能 export compact 命令,该命令简化了导出的参数,仅导出修改的配置,系统默 认配置参数将不 ...

  10. [UE4]IES光源概述文件

    IES Light Profiles(IES光源概述文件) 是一条曲线,该曲线在一段弧线中定义了光源强度,虚幻引擎4将会围绕某个轴旋转该弧线,从而使得 点光源 (和从技术上讲的 聚光源,下面会提供更多 ...