一、环境
<spring-cloud.version>Dalston.SR1</spring-cloud.version>
注意这个:
<java.version>1.8</java.version>
<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>
二、 encrypt: key: 必须是放在这个名称 bootstrap.yml 的文件里
我开始放在application.properties不生效,查了好长时间,https://github.com/spring-cloud/spring-cloud-config/issues/767
三、bootstrap.yml
server:
port: 8000
spring:
application:
name: mdjr-eureka
eureka:
instance:
hostname: localhost
client:
fetch-registry: false #是否检索服务
register-with-eureka: false #是否向服务注册中心注册自己
server:
enable-self-preservation: false #保护机制
encrypt:
key: nicai
security:
basic:
enabled: true
user:
name: zdl
password: '{cipher}3646313a9ee60c34cbb9b13bad74a818e4d1eb40bcf64f636ca7974329d867c2'
四、对称加密 yml 文件里 必须加引号
password: '{cipher}3646313a9ee60c34cbb9b13bad74a818e4d1eb40bcf64f636ca329d867c2'
对称加密参考:https://blog.csdn.net/hjbbjh0521/article/details/80362763
eureka 依赖的jar 包里没有 /encrypt 接口,所以生产密文最好正在 configServer 工程里做