Spring CLI v2.1.0.RELEASE - encrypt -> NoSuchMethodError



当我运行时:

spring encrypt totallysecretpassword --key=insanity

线程"main"java.lang.reflect.InvocationTargetException中的异常在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法(位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62(在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43(位于java.lang.reflect.Method.ioke(Method.java:498(网址:org.springframework.bootloader.MainMethodRunner.run(MainMethodRunner.java:48(网址:org.springframework.bootloader.Launcher.launch(Launcher.java:87(网址:org.springframework.bootloader.Launcher.launch(Launcher.java:50(网址:org.springframework.bootloader.JarLauncher.main(JarLauncher.java:51(导致原因:java.lang.NoSuchMethodError:org.springframework.cloud.cli.command.encrypt.BaseEncryptOptionHandler.option(Ljava/util/Collection;Ljava/lang/String;(Ljoptsimple/OptionsSpecBuilder;网址:org.springframework.cloud.cli.command.encrypt.BaseEncryptOptionHandler.options(BaseEncryptOptionHandler.java:53(位于org.springframework.boot.cli.command.options.OptionHandler.getParser(OptionHandler.java:68(位于org.springframework.boot.cli.command.options.OptionHandler.run(OptionHandler.java:83(位于org.springframework.boot.cli.command.OptionsParsingCommand.run(OptionParsingCommand.java:54(位于org.springframework.boot.cli.command.CommandRunner.run(CommandRunner.java:219(位于org.springframework.boot.cli.command.CommandRunner.runAndHandleErrors(CommandRunner.java:171(网址:org.springframework.boot.cli.SpringCli.main(SpringCli.java:63(…还有8个

我按照这里的说明重新安装了JCE:https://cloud.spring.io/spring-cloud-cli/

基本上,我想要的是:https://blog.novatec-gmbh.de/encrypted-properties-spring/

但在1.3.2中也是同样的错误,所以我使用了最新的。。。但仍然没有成功。。。我错过了什么?

--没有在我的windows盒子上运行2.0.8的加密,@jtim在ubuntu盒子上运行时的回答让我很担心!

这是对spring-boot-cli的突破性更改。只需等待兼容版本的spring-cloud-cli的发布(新版本的请求(。

或者,您可以安装一个没有更改的旧版本的spring-boot-cli,例如2.0.8.RELEASE

刚刚遇到了同样的问题。使用Sdkman,你可以快速降级到一个运行良好的版本:

sdk ls springboot
sdk use springboot 2.0.8.RELEASE
spring install org.springframework.cloud:spring-cloud-cli:2.0.0.RELEASE

使用较低版本的Spring boot-cli。以下配置对我有效:

Springboot cli版本:2.1.6.RELEASE

创建系统变量

name: SPRING_HOME

value: C:UserszafrullahsyedDownloadsspring-2.1.6.RELEASE

将bin文件夹添加到系统路径:%SPRING_HOME%bin

以管理员身份打开CMD,否则不会在spring-2.1.6.RELEASElibext文件夹上创建jar

检查Spring——版本

Spring CLI v2.1.6.RELEASE

然后安装sping云插件:

spring install org.springframework.cloud:spring-cloud-cli:2.1.0.RELEASE

spring encrypt mysecret --key foo

加密值:1c656a1a4617146a7e76d977ca5fa2cfeb0afecc5655677193f53ab43578dd4d

spring decrypt --key foo 1c656a1a4617146a7e76d977ca5fa2cfeb0afecc5655677193f53ab43578dd4d

解密值:

mysecret

我也遇到了这个问题,以下是我所做的,

# Step 1: Download the binaries to install (https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/)
$ wget https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/2.0.8.RELEASE/spring-boot-cli-2.0.8.RELEASE-bin.tar.gz
# Step 2: Extract the tar.gz
$ tar xvf spring-boot-cli-2.0.8.RELEASE-bin.tar.gz
# Step 3: Enable execute permissions
$ chmod +x spring-2.0.8.RELEASE/bin/spring
# Install Spring Cloud
$ spring install org.springframework.cloud:spring-cloud-cli:2.0.0.RELEASE
# Step 5: Add it to your PATH
$ cd spring-2.0.8.RELEASE/bin
$ echo "PATH=$(pwd):$PATH" >> .bashrc or  .zshrc

这通常适用于Mac和任何基于Linux的系统。我亲自在Mac和Linux Mint 上尝试过

输出:

$ spring encrypt totallysecretpassword --key=insanity
f5a7944890c871ef58971eeaf123bbc750727b012cce8f7072def5bf71b000fb00089e106775ac0306b5f15b8f17d233

希望这能帮助到别人。

最新更新