【问题标题】:Is there a value for the Sprint Boot @ConfigurationProperties compatible with both Eclipse IDE and InteliJ IDEA?Sprint Boot @ConfigurationProperties 是否与 Eclipse IDE 和 InteliJ IDEA 兼容?
【发布时间】:2020-05-23 12:10:37
【问题描述】:

拥有一个带有运行状况执行器端点的简单 Sprint Boot 应用程序,允许您在 application.properties 中指定和绑定此类属性(以下列可接受的方式之一):

# Eclipse IDE
management.endpoint.health.show-details=when-authorized
# or
# InteliJ IDEA
management.endpoint.health.show-details=when_authorized

此属性的值是 Enum 类型之一。

由于 Spring Boot @ConfigurationProperties 注释的 Relaxed Binding 特性,这两种变体都被接受。

虽然从 Spring 和 Maven 构建的角度来看,这两个值都是有效的,但两个 IDE 中的每一个都只会建议(自动完成、悬停文档、ctrl-click-navigate-to-definition)他们自己的值版本属性,如果使用另一个则报错。

有没有办法让两个世界都快乐?

【问题讨论】:

    标签: eclipse spring-boot intellij-idea compatibility properties-file


    【解决方案1】:

    找到了一个让每个人(几乎)都开心的版本(Maven、InteliJ IDEA、Eclipse):

    management.endpoint.health.show-details=WHEN_AUTHORIZED
    

    Spring Boot 实现是这样定义的,使用这种形式,几乎每个人都很高兴。

    Eclipse IDE * 如果您键入“W”,自动完成将跟随大写 * 悬停文档和代码导航都有效

    InteliJ IDEA * 自动补全不会提示大写版本(但使用时不会显示错误) * 悬停文档和代码导航都有效

    而 Maven 并不关心,因为 Spring Boot 在这里使用的是宽松的绑定规则。

    【讨论】:

      【解决方案2】:

      这是 IDEA 中的一个已知问题。请投票/关注:https://youtrack.jetbrains.com/issue/IDEA-171730

      【讨论】:

        猜你喜欢
        • 2015-09-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-25
        • 1970-01-01
        • 2010-09-18
        • 2023-03-23
        • 1970-01-01
        相关资源
        最近更新 更多