embedded-tomcat-7

Spring Boot - How to get the running port

女生的网名这么多〃 提交于 2019-11-26 06:36:22
问题 I have a spring boot application (using embedded tomcat 7), and I\'ve set server.port = 0 in my application.properties so I can have a random port. After the server is booted up and running on a port, I need to be able to get the port that that was chosen. I cannot use @Value(\"$server.port\") because it\'s zero. This is a seemingly simple piece of information, so why can\'t I access it from my java code? How can I access it? 回答1: Is it also possible to access the management port in a similar

How to create JNDI context in Spring Boot with Embedded Tomcat Container

谁都会走 提交于 2019-11-26 03:08:10
问题 import org.apache.catalina.Context; import org.apache.catalina.deploy.ContextResource; import org.apache.catalina.startup.Tomcat; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; import org.springframework.boot.context.embedded.tomcat