简体   繁体   English

无法使用 jasypt 加密进行 maven 发布

[英]Not able to do maven release with jasypt encryption

I've a Springboot project handled by maven that contains some secrets encrypted with Jasypt.我有一个由 maven 处理的 Springboot 项目,其中包含一些用 Jasypt 加密的秘密。 When I'm running the mvn deploy I'm passing the jasypt password as:当我运行mvn deploy时,我将 jasypt 密码传递为:

mvn -B clean deploy -Djasypt.encryptor.password=${jasypt_password}

And it is able to run test cases and deploy the jar file to repository.它能够运行测试用例并将 jar 文件部署到存储库。 But when I'm doing the same with mvn release the jasypt password is not properly set.但是当我对mvn release做同样的事情时,jasypt 密码设置不正确。

mvn -B clean release:prepare release:perform -Djasypt.encryptor.password=${jasypt_password}

Or或者

mvn -B release:prepare -Djasypt.encryptor.password=${jasypt_password}

For both these cases, I'm getting following error while running the test cases.对于这两种情况,我在运行测试用例时都会遇到以下错误。

Caused by: java.lang.IllegalStateException: Required Encryption configuration property missing: jasypt.encryptor.password原因:java.lang.IllegalStateException:缺少必需的加密配置属性:jasypt.encryptor.password

The plugin configuration I'm using is:我正在使用的插件配置是:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.5.3</version>
        <configuration>
            <localCheckout>true</localCheckout>
        </configuration>
</plugin>

How should I set jasypt password while running the maven release?运行 maven 版本时我应该如何设置 jasypt 密码?

You can check this link which gives more details about the issue. 您可以查看此链接 ,其中提供有关该问题的更多详细信息。

Basically it states that 基本上它说明了这一点

Once you enable jasypt-spring-boot the password property is required as specified in the documentation 启用jasypt-spring-boot后,需要使用文档中指定的密码属性

They have suggested multiple solutions. 他们提出了多种解决方案。 One of them being: 其中一个是:

Add jasypt.encryptor.password=dummy to your springboot properties file. jasypt.encryptor.password=dummy添加到springboot属性文件中。

And another (if running from command line), run your jar with 另一个(如果从命令行运行),运行你的jar

-Djasypt.encryptor.password=*******************

I got the issue solved using following command. 我使用以下命令解决了问题。 Apparently maven release plugin takes configuration parameters in a different way. 显然,maven发布插件以不同的方式获取配置参数。

mvn -B clean release:prepare release:perform -Darguments="-Djasypt.encryptor.password=${jasypt_password}"

If you are using Intellij,如果您使用 Intellij, 在此处输入图像描述

Using -Djasypt.encryptor.password=${jasypt_password} as Project argument should resolve your issue.使用-Djasypt.encryptor.password=${jasypt_password}作为 Project 参数应该可以解决您的问题。

If it doesnot help then try --jasypt.encryptor.password=${jasypt_password} .如果没有帮助,请尝试--jasypt.encryptor.password=${jasypt_password}

Let me know if this helps.让我知道这是否有帮助。

Thanks,谢谢,
Manu马努

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM