首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring-boot-maven-plugin @ConditionalOnProperty

spring-boot-maven-plugin @ConditionalOnProperty
EN

Stack Overflow用户
提问于 2021-12-13 08:51:42
回答 1查看 170关注 0票数 0

在使用spring maven-plugin启动应用程序时,我尝试使用@ConditionalOnProperty。

如果我用eclipse启动项目,我只需将-Dexample=true添加到vm参数中即可。

代码语言:javascript
复制
@ConditionalOnProperty( name = "example", havingValue = "true", matchIfMissing = false )

我也试图在spring maven-plugin上做同样的事情:

代码语言:javascript
复制
<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>

但这些都不管用。

如果我添加了一个配置文件

代码语言:javascript
复制
<jvmArguments>-Dspring.profiles.active=exampleProfile</jvmArguments>

其中包含它工作的参数example:true

编辑:

确切的论点是

代码语言:javascript
复制
<arguments>
    <argument>openapi.offline=true</argument>
</arguments>

但财产仍未找到

代码语言:javascript
复制
- @ConditionalOnProperty (openapi.offline=true) did not find property 'offline'

我的条件是:

代码语言:javascript
复制
 @ConditionalOnProperty( prefix = "openapi", name = "offline", havingValue = "true", matchIfMissing = false )

解决方案:

我有过多次

代码语言:javascript
复制
<jvmArguments> -example1 </jvmArguments>
<jvmArguments> -example2 </jvmArguments>

但他们互相凌驾。所以我不得不把它们放在一个jvmarguments字段中

代码语言:javascript
复制
<jvmArguments> -example1 -example2 </jvmArguments>
EN

回答 1

Stack Overflow用户

发布于 2021-12-13 09:09:44

您不需要-D,请尝试如下:

代码语言:javascript
复制
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>....</version>
    <configuration>
      <arguments>
        <argument>--openapi.offline=true</argument>
      </arguments>
    </configuration>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70331971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档