Skip to content

Introduce 'value' attribute in @SpringApplicationConfiguration #3635

@sbrannen

Description

@sbrannen

Issue #3400 retrofitted @SpringApplicationConfiguration to use the new @AliasFor annotation from Spring Framework 4.2 to introduce explicit annotation attribute overrides.

Due to the opinionated view of Spring Boot with regard to favoring @Configuration classes over XML and Groovy configuration, @SpringApplicationConfiguration can benefit from yet another feature of @AliasFor. Namely, @SpringApplicationConfiguration can introduce a new value attribute that is an attribute override for the classes attribute in @ContextConfiguration.

Proposed change:

// ...
public @interface SpringApplicationConfiguration {

    /**
     * @return the context configuration classes
     * @see ContextConfiguration#classes
     * @see #classes
     */
    @AliasFor(annotation = ContextConfiguration.class, attribute = "classes")
    Class<?>[] value() default {};

    // ...
}

Consequently, if a Spring Boot integration test only needs to declare a configuration class, the declaration can be simplified as follows: @SpringApplicationConfiguration(SampleApplication.class).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions