Skip to content

io microsphere spring cloud client condition ConditionalOnFeaturesAvailable

github-actions[bot] edited this page Jun 10, 2026 · 2 revisions

ConditionalOnFeaturesAvailable

Type: Annotation | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.condition | Since: 1.0.0

Source: microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesAvailable.java

Overview

org.springframework.context.annotation.Conditional that only matches when Spring Cloud features are enabled and the FeaturesEndpoint is available.

This annotation combines ConditionalOnFeaturesEnabled and ConditionalOnAvailableEndpoint to ensure that the annotated component is only created if the application has explicitly enabled Spring Cloud features (via the property defined in CommonsPropertyConstants#FEATURES_ENABLED_PROPERTY_NAME) and the FeaturesEndpoint actuator endpoint is exposed and accessible.

Example Usage

{@code

### Declaration

```java
public @interface ConditionalOnFeaturesAvailable
```

**Author:** Mercy

## Version Information

- **Introduced in:** `1.0.0`
- **Current Project Version:** `0.2.18-SNAPSHOT`

## Version Compatibility

This component is tested and compatible with the following Java versions:

| Java Version | Status |
|:---:|:---:|
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |

## Examples

```java
@Configuration
@ConditionalOnFeaturesAvailable
public class MyFeatureConfiguration {

    @Bean
    public MyService myService() {
        return new MyService();
    }
}
```

## Usage

### Maven Dependency

Add the following dependency to your `pom.xml`:

```xml

    io.github.microsphere-projects
    microsphere-spring-cloud-commons
    ${microsphere-spring-cloud.version}

```

> **Tip:** Use the BOM (`microsphere-spring-cloud-dependencies`) for consistent version management. See the [Getting Started](https://github.com/microsphere-projects/microsphere-spring-cloud#getting-started) guide.

### Import

```java
import io.microsphere.spring.cloud.client.condition.ConditionalOnFeaturesAvailable;
```

## See Also

- `ConditionalOnFeaturesEnabled`
- `ConditionalOnAvailableEndpoint`
- `FeaturesEndpoint`

---

*This documentation was auto-generated from the source code of [microsphere-spring-cloud](https://github.com/microsphere-projects/microsphere-spring-cloud).*

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally