Skip to content

shyamz-22/conditional-profiles

Repository files navigation

Conditional Profiles

Build Status codecov MavenCentral License: MIT

Default Spring profile behavior

Creates the bean when Profile A OR B is active.

@Bean
@Profile("A", "B")
public ExampleBean exampleBean() {
  return new ExampleBean();
}

Conditional On Profiles

Creates the bean only when Profile A AND B are active.

@Bean
@ConditionalOnProfiles("A","B")
public ExampleBean exampleBean() {
  return new ExampleBean();
}

Installation

Gradle

compile 'io.github.shyamz-22:conditional:0.0.2'

Maven

<dependency>
    <groupId>io.github.shyamz-22</groupId>
    <artifactId>conditional</artifactId>
    <version>0.0.2</version>
</dependency>