首页 > 技术文章 > yml文件中配置对称加密{cipher}无法识别

DiZhang 2020-02-27 08:58 原文

错误文件

info:
  profile: dev
  from: config/dev
  secretValue: {cipher}9ae2d08f248ab77561cbea8fe88566b7665f8ad65527e7757dcf1cd3bffe1aae

错误原因

yml对格式要求比较严格,使用 {cipher}时需要加上 ‘’,否则无法识别

解决方法

方法一:yml文件修改为一下格式

info:
  profile: dev
  from: config/dev
  secretValue: '{cipher}9ae2d08f248ab77561cbea8fe88566b7665f8ad65527e7757dcf1cd3bffe1aae'

方法二:使用.properties格式代替yml格式

xxx.properties

secretValue={cipher}9ae2d08f248ab77561cbea8fe88566b7665f8ad65527e7757dcf1cd3bffe1aae

推荐阅读