[英]How to attach VM options for maven command line
how can I add an arguments in maven command line defined as VM option.如何在定义为 VM 选项的 maven 命令行中添加 arguments。 In Intellij I have the configuration在 Intellij 我有配置
java 11 -Djasypt.encryptor.password=xxx
That solution works perfectly when I am reading VM option using @Value annotation in configuration class.当我在配置 class 中使用 @Value 注释读取 VM 选项时,该解决方案非常有效。
@Value("${jasypt.encryptor.password}")
private String jasyptEncryptorPassword;
I am using following command mvn -Djasypt.encryptor.password=xx spring-boot:run But it failed to fetch with following error.我正在使用以下命令 mvn -Djasypt.encryptor.password=xx spring-boot:run 但它无法获取以下错误。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jasyptConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jasypt.encryptor.password' in value "${jasypt.encryptor.password}"
Only for command java -jar is possible to attach VM options?仅对于命令 java -jar 可以附加 VM 选项吗?
You can attach the VM options to the spring boot plugin as below:您可以将 VM 选项附加到 spring 引导插件,如下所示:
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Djasypt.encryptor.password=xxx"
check the docs for the plugin here: spring-boot-maven-plugin docs在此处检查插件的文档: spring-boot-maven-plugin docs
Other option would be to set it in the pom.xml
其他选项是在pom.xml
中设置它
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Djasypt.encryptor.password=xxx
</jvmArguments>
</configuration>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.