博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring cloud: eureka搭建
阅读量:6840 次
发布时间:2019-06-26

本文共 4005 字,大约阅读时间需要 13 分钟。

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/

转载于:https://www.cnblogs.com/maohuidong/p/9881022.html

你可能感兴趣的文章
关于jmeter里的自动重定向的使用-小强性能测试培训班学生作品
查看>>
如何提高Linux系统应对短连接的负载能力
查看>>
Django 数据库表多对多的创建和增删改查
查看>>
大數據下的決策思考
查看>>
hadoop作业分片处理以及任务本地性分析(源码分析第一篇)
查看>>
又睡不着了。。
查看>>
RHEL在VLAN Trunk模式下的IP地址配置
查看>>
RHCE 学习笔记(38 ) - Shell
查看>>
WEB服务器-Nginx之虚拟主机、日志、认证及优化
查看>>
常用的两种数据分区方法(以Teradata为例)
查看>>
Nginx Rewrite正则表达式案例
查看>>
一个新兴的日志管理产品
查看>>
WindowsServer2012史记-安装和配置HyperV
查看>>
Delphi开发的IOCP测试Demo以及使用说明。
查看>>
10分钟学会 Python 函数基础知识
查看>>
应届毕业生求职之我见
查看>>
FAQ:configuration manager未找到站点来管理此客户端
查看>>
微博商城开启社会化电商之路
查看>>
通过脚本案例学习shell(三) --- 通过交互式脚本自动创建Apache虚拟主机
查看>>
在大二,我是怎么月收入5000
查看>>