在使用spring maven-plugin启动应用程序时,我尝试使用@ConditionalOnProperty。
如果我用eclipse启动项目,我只需将-Dexample=true添加到vm参数中即可。
@ConditionalOnProperty( name = "example", havingValue = "true", matchIfMissing = false )我也试图在spring maven-plugin上做同样的事情:
<jvmArguments>-Dexample=true</jvmArguments>
<jvmArguments>-Dspring-boot.run.arguments="--example=true"</jvmArguments>
<arguments>
<argument>-Dexample=true</argument>
<argument>-Dspring-boot.run.arguments="--example=true"</argument>
</arguments>但这些都不管用。
如果我添加了一个配置文件
<jvmArguments>-Dspring.profiles.active=exampleProfile</jvmArguments>其中包含它工作的参数example:true。
编辑:
确切的论点是
<arguments>
<argument>openapi.offline=true</argument>
</arguments>但财产仍未找到
- @ConditionalOnProperty (openapi.offline=true) did not find property 'offline'我的条件是:
@ConditionalOnProperty( prefix = "openapi", name = "offline", havingValue = "true", matchIfMissing = false )解决方案:
我有过多次
<jvmArguments> -example1 </jvmArguments>
<jvmArguments> -example2 </jvmArguments>但他们互相凌驾。所以我不得不把它们放在一个jvmarguments字段中
<jvmArguments> -example1 -example2 </jvmArguments>发布于 2021-12-13 09:09:44
您不需要-D,请尝试如下:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>....</version>
<configuration>
<arguments>
<argument>--openapi.offline=true</argument>
</arguments>
</configuration>https://stackoverflow.com/questions/70331971
复制相似问题