我正在使用 JHipster 注册表 APP,并通过使用 Jasypt 库从所有微服务的集中配置中加密用户名和密码来使用本地加密。
在执行此操作时,我观察到我尝试加密默认用户名和密码(admin/admin)的那一刻,在中央配置文件夹中加密如下所述,我已经配置了 gateway.yml(所有微服务通用配置的中央配置文件)
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/gateway?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
**username: ENC(HLr1wJLGRZPuHVMUgEhiUQ==)
password: ENC(HLr1wJLGRZPuHVMUgEhiUQ==)**
hikari:
poolName: Hikari
auto-commit: false
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
jpa:
database-platform: org.hibernate.dialect.MySQLInnoDBDialect
database: MYSQL
openInView: false
show-sql: true
liquibase:
drop-first: true
# Remove 'faker' if you do not want the sample data to be loaded automatically
contexts: dev
eureka:
instance:
prefer-ip-address: true
client:
service-url:
defaultZone:
# Jasypt Encryptor property================
http://**ENC(iNeA5NB8uu+MIXdPXBNzSw==):ENC(iNeA5NB8uu+MIXdPXBNzSw==)**@localhost:8761/eureka/
# ===========================================
# Jasypt Encryptor property
#============================================
jasypt:
encryptor:
password: jasyptkey
我也为 Jasypt-maven spring boot starter 配置添加了所需的依赖项到注册表应用程序项目,如下所示,它编译并显示注册表也完美
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
我面临的问题是发现客户端/云配置服务器客户端无法识别端点 URI。
我也分享了微服务应用程序(网关)中的bootstrap.yml文件以供参考,如果那里有任何遗漏。
微服务应用bootstarp.yml文件是这样的
spring:
application:
name: gateway
profiles:
active: dev
include: composite
cloud:
config:
fail-fast: false
uri: http://admin:${jhipster.registry.password}@localhost:8761/config/decrypt
# name of the config server's property source (file.yml) that we want to use
name: gateway
profile: dev
请建议在配置或任何其他替代方法时出现问题,或者它不支持基于 Jasypt 的加密/解密或需要配置更多的东西?