jasypt-spring-boot提示Failed to bind properties
2024-09-07 00:41:06
1 问题描述
在Spring Boot中使用jasypt-spring-boot进行加密,但是提示:
Description:
Failed to bind properties under 'spring.datasource.password' to java.lang.String:
Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String
Action:
Update your application's configuration
或提示
Description:
Failed to bind properties under 'spring.datasource.url' to java.lang.String:
Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String
Action:
Update your application's configuration
最后的异常是这个:
2 解决办法
查阅了相关issue,发现是3.0.2更改了默认的加密算法,最后的办法是把版本降到2.1.2:
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
接着重新加密配置,但是2.1.2不支持使用环境变量作为加密的口令,在IDEA中测试的时候需要在运行配置加上
-Djasypt.encryptor.password=xxxx
部署到Tomcat时添加环境变量:
export JAVA_OPTS="-Djasypt.encryptor.password=xxxx"
最新文章
- .NET面试题系列[1] - .NET框架基础知识(1)
- JS魔法堂:属性、特性,傻傻分不清楚
- CPU MPU MCU SOC SOPC关系及区别
- .NET设计模式(11):组合模式(Composite Pattern)(转)
- 用IDEA调试Play工程
- WTL---WxWidget---MFC 何去何从
- ASP.NET MVC Url中带点号出现404错误的解决方案
- SSM框架整合,以CRM为例子
- deeplearning.ai 神经网络和深度学习 week3 浅层神经网络 听课笔记
- js高阶函数应用—函数防抖和节流
- python 可迭代对象 迭代器 生成器总结
- AJAX里使用的弹窗样式 tanchuang.js tanchuang.css
- json2.js 序列化 和反序列化 转
- 样条之EHMT插值函数
- linux命令(46):程序运行前后台切换
- Python mysql-数据库基础知识
- 《JavaScript 实战》:实现图片幻滑动展示效果
- [android] AndroidManifest.xml -【manifest】
- java 问题
- jq from表单 取值