Get the server port number from tomcat without a request

前端 未结 12 1595
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 06:32

Is there any Tomcat API or configuration available which can tell an application (probably on startup), what port its running on without a request?

Imagine a scenari

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 07:21

    I am not entirely sure if you can access the Tomcat port from code in the environment configuration you need. Did you consider actually having the full URL to the web service passed as a configuration param/setting (probably in a .properties file) to the app?

    This way you wouldn't have to hardcode the port and de-couple both your apps so that you could technically have the web service on an external tomcat but still access it by just changing the property, avoiding code re-build.

提交回复
热议问题