Skip to content

Instantly share code, notes, and snippets.

@j-tim
Created May 1, 2020 15:50
Show Gist options
  • Save j-tim/c55b96619ed612ca897788288d285088 to your computer and use it in GitHub Desktop.
Save j-tim/c55b96619ed612ca897788288d285088 to your computer and use it in GitHub Desktop.
Spring Boot 2.3.0 @ConditionalOnWarDeployment example
package nl.jtim.conditional.on.war.deployment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWarDeployment;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Service
@ConditionalOnWarDeployment
public class SomeService {
public SomeService() {
log.info("I'm still running in a Servlet container or application server :(");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment