批注接口 ConditionalOnAvailableEndpoint


@Retention(RUNTIME) @Target({METHOD,TYPE}) @Documented @Conditional(org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnAvailableEndpointCondition.class) public @interface ConditionalOnAvailableEndpoint
@Conditional that checks whether an endpoint is available. An endpoint is considered available if it is both enabled and exposed on the specified technologies.

Matches enablement according to the endpoints specific Environment property, falling back to management.endpoints.enabled-by-default or failing that Endpoint.enableByDefault().

Matches exposure according to any of the management.endpoints.web.exposure.<id> or management.endpoints.jmx.exposure.<id> specific properties or failing that to whether any EndpointExposureOutcomeContributor exposes the endpoint.

Both enablement and exposure conditions should match for the endpoint to be considered available.

When placed on a @Bean method, the endpoint defaults to the return type of the factory method:

 @Configuration
 public class MyConfiguration {

     @ConditionalOnAvailableEndpoint
     @Bean
     public MyEndpoint myEndpoint() {
         ...
     }

 }

It is also possible to use the same mechanism for extensions:

 @Configuration
 public class MyConfiguration {

     @ConditionalOnAvailableEndpoint
     @Bean
     public MyEndpointWebExtension myEndpointWebExtension() {
         ...
     }

 }

In the sample above, MyEndpointWebExtension will be created if the endpoint is available as defined by the rules above. MyEndpointWebExtension must be a regular extension that refers to an endpoint, something like:

 @EndpointWebExtension(endpoint = MyEndpoint.class)
 public class MyEndpointWebExtension {

 }

Alternatively, the target endpoint can be manually specified for components that should only be created when a given endpoint is available:

 @Configuration
 public class MyConfiguration {

     @ConditionalOnAvailableEndpoint(endpoint = MyEndpoint.class)
     @Bean
     public MyComponent myComponent() {
         ...
     }

 }
从以下版本开始:
2.2.0
作者:
Brian Clozel, Stephane Nicoll, Andy Wilkinson, Phillip Webb
另请参阅:
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    The endpoint type that should be checked.
    Technologies to check the exposure of the endpoint on while considering it to be available.
    Alias for endpoint().
  • 元素详细资料

    • value

      @AliasFor(attribute="endpoint") Class<?> value
      Alias for endpoint().
      返回:
      the endpoint type to check
      从以下版本开始:
      3.4.0
      默认值:
      java.lang.Void.class
    • endpoint

      @AliasFor(attribute="value") Class<?> endpoint
      The endpoint type that should be checked. Inferred when the return type of the @Bean method is either an @Endpoint or an @EndpointExtension.
      返回:
      the endpoint type to check
      默认值:
      java.lang.Void.class
    • exposure

      EndpointExposure[] exposure
      Technologies to check the exposure of the endpoint on while considering it to be available.
      返回:
      the technologies to check
      从以下版本开始:
      2.6.0
      默认值:
      {}