Created
August 4, 2023 02:53
-
-
Save sandipchitale/e4952000b89d6bb9eec2e338a44d9807 to your computer and use it in GitHub Desktop.
Running as War or Standalone Springboot App #springboot #war #notwar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
@ConditionalOnWebApplication | |
@ConditionalOnNotWarDeployment() | |
public CommandLineRunner clrNotInWar() { | |
return (args) -> { | |
System.out.println("Not running as war!"); | |
}; | |
} | |
static class OnWarDeployment extends NoneNestedConditions { | |
OnWarDeployment() { | |
super(ConfigurationPhase.REGISTER_BEAN); | |
} | |
@ConditionalOnNotWarDeployment() | |
static class OnWar{} | |
} | |
@Bean | |
@ConditionalOnWebApplication | |
@Conditional(OnWarDeployment.class) | |
public CommandLineRunner clrOnWar() { | |
return (args) -> { | |
System.out.println("Running as war!"); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment