Created
January 3, 2019 12:44
-
-
Save rbaul/4dacb0274e25e5bdbf959703fe0943e2 to your computer and use it in GitHub Desktop.
Spring Application get server context path
This file contains 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
server: | |
context-path: /my-context // Caused by: java.lang.IllegalArgumentException: ContextPath must start with '/' and not end with '/' | |
port: 8080 |
This file contains 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
@Slf4j | |
@Component | |
public class AppStartupRunner implements ApplicationRunner { | |
@Autowired | |
private ServletContext servletContext; | |
@Override | |
public void run(ApplicationArguments args) throws Exception { | |
log.info(">>>>>>> Context Path is : {}", servletContext.getContextPath()); // Result: "/my-context" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment