简体   繁体   English

spring-boot-maven-plugin @ConditionalOnProperty

[英]spring-boot-maven-plugin @ConditionalOnProperty

i am trying to use @ConditionalOnProperty while starting the application with the spring-boot-maven-plugin.我在使用 spring-boot-maven-plugin 启动应用程序时尝试使用 @ConditionalOnProperty。

if i start the project with eclipse i just have to add "-Dexample=true" to the vm Arguments.如果我使用 eclipse 开始项目,我只需将“-Dexample=true”添加到 vm Arguments。

@ConditionalOnProperty( name = "example", havingValue = "true", matchIfMissing = false )

i tried to do the same ith the spring-boot-maven-plugin我尝试对 spring-boot-maven-plugin 做同样的事情

i tried it with我试过了

<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>

but none of these works.但这些都不起作用。

if i add a profile如果我添加个人资料

             <jvmArguments>-Dspring.profiles.active=exampleProfile</jvmArguments>

which contains the argument example:true it works.其中包含参数example:true它有效。 ` `

EDIT:编辑:

the exact arguement is确切的论点是

<arguments>
 <arguement>openapi.offline=true</arguement>
</arguments>

but the property is still not found但仍未找到该属性

- @ConditionalOnProperty (openapi.offline=true) did not find property 'offline'

my conditional:我的条件:

 @ConditionalOnProperty( prefix = "openapi", name = "offline", havingValue = "true", matchIfMissing = false )

you don't need the -D Try this:你不需要-D试试这个:

    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>....</version>
    <configuration>
      <arguments>
        <argument>--openapi.offline=true</argument>
      </arguments>
    </configuration>

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

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