Skip to content

io microsphere spring context annotation OverrideAnnotationAttributes

github-actions[bot] edited this page Jun 18, 2026 · 5 revisions

OverrideAnnotationAttributes

Type: Annotation | Module: microsphere-spring-context | Package: io.microsphere.spring.context.annotation | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/context/annotation/OverrideAnnotationAttributes.java

Overview

The meta-annotation that indicates the attributes of the annotation should be overridden.

The annotation must Import @Import an ImportBeanDefinitionRegistrar or ImportSelector implementation that must extend the abstract class BeanCapableImportCandidate or it subtype.

Example Usage

{@code
// Define a custom annotation with an override strategy

### Declaration

```java
public @interface OverrideAnnotationAttributes
```

**Author:** Mercy

## Version Information

- **Introduced in:** `1.0.0`
- **Current Project Version:** `0.2.27-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
// Define a custom annotation with an override strategy
@OverrideAnnotationAttributes(strategy = MyCustomStrategy.class)
@Import(MyImportRegistrar.class)
public @interface MyCustomImport {
    String value() default "";
}

// In your ImportSelector or ImportBeanDefinitionRegistrar implementation:
public class MyImportRegistrar extends BeanCapableImportCandidate implements ImportBeanDefinitionRegistrar {
    public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
         // ...
    }
}

// Define an override strategy
public class MyCustomStrategy implements OverrideAnnotationAttributesStrategy {
    @Override
    public AnnotationAttributes override(AnnotationAttributes originalAttributes, Class extends Annotation> annotationType, AnnotationMetadata metadata) {
        // Custom logic to modify attributes
        return originalAttributes;
    }
}

@MyCustomImport
public class AppConfig { }
```

## Usage

### Maven Dependency

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

```xml

    io.github.microsphere-projects
    microsphere-spring-context
    ${microsphere-spring.version}

```

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

### Import

```java
import io.microsphere.spring.context.annotation.OverrideAnnotationAttributes;
```

## See Also

- `OverrideAnnotationAttributesStrategy`
- `ConfigurationPropertyOverrideAnnotationAttributesStrategy`
- `BeanCapableImportCandidate#getOverriddenAnnotationAttributes`
- `Import`

---

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

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally