Jasypt这个Java类包为开发人员提供一种简单的方式来为项目增加加密功能,包括:密码Digest认证,文本和对象加密,集成hibernate,Spring Security(Acegi)来增强密码管理。Jasypt开发团队推出了Java加密工具Jasypt 1.4,它可与Spring Framework、Hibernate和Acegi Security集成;
详情见URL
springboot 集成jasypt
首先是版本选择 建议:
springboot版本 | jasypt版本 |
---|---|
2.1.0 | 2.1.0 |
1.4.2 | 1.5 |
1.5.3 | 1.5 |
本文主要介绍 springboot1.4.2版本的集成数据库密码加密
首先 pom 文件引入
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.5</version>
</dependency>
cmd窗口 执行命名行
java -cp C:\.m2\repository\org\jasypt\jasypt\1.9.2\jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="数据库密码" password=盐值 algorithm=PBEWithMD5AndDES
以及对应的
注意: 尽量选用版本高的mybaits 以及 tk.mybatis 插件引用,
这样才能避免更多坑
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
本文引用的2.1.5
之前引用低版本的会报错 如下
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘mapperHelper’ of bean class [org.mybatis.spring.mapper.MapperFactoryBean]: Bean property ‘mapperHelper’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
升级了版本就解决了