Skip to content

To-da/spring-example-conditional

Repository files navigation

Custom @Conditional annotation example

What is @Conditional

@Conditional is an annotation added to Spring 4 to specify condition(s) under which specific configuration will be processed or specific bean will be registered to the Spring context.

Why is important

Spring Boot project auto-configuration support rely on @Conditional - it has own stereotype annotations like @ConditionalOnClass or @ConditionalOnBean to initialize Spring context in order to dependencies on classpath (or other custom condition annotations applicable to any other condition).

This example

This sample shows how to register specifics bean to the Spring context in order to JVM vendor on platform where you running this example. Run Application.java (by simply run the main method [in your IDE] or ./gradlew run [unix] or gradlew.bat run [windows] or build jar and run like java -jar build/lib/spring-boot-example-conditional---*.jar).

Video

Related youtube video

About

Example of the custom Spring 4 @conditional annotation with Spring Boot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages