问题描述
我使用 jasypt 作为我的 springboot 应用程序,如下所示
当我尝试通过命令行通过 -D 传递密码时,它不起作用,它只能通过@Bean 起作用
任何提示或想法?
mvn -Djasypt.encryptor.password=**** spring-boot:run
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
@Bean(name = "jasyptStringEncryptor")
public StringEncryptor getpasswordEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
//config.setPassword("******"); // encryptor's private key
config.setAlgorithm("PBEWithMD5AndTripleDES");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
return encryptor;
}
错误如下
Caused by: java.lang.NullPointerException: null
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getpasswordChararray(SimplePBEConfig.java:487) ~[jasypt-1.9.3.jar:na]
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:842) ~[jasypt-1.9.3.jar:na]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)