在使用Java中使用嵌入式服务器时,如何将Tomcat版本隐藏在错误消息中
我有一个Java应用程序,我正在使用嵌入式的tomcat服务器, 看起来这样,
Tomcat tomcat = new Tomcat()
我在这里创建了嵌入式的tomcat服务器。
问题语句
如何将其隐藏在Java中?
我有一个想法,我需要覆盖 serverinfo.properties ,但是我该怎么做?
I have a java application where i'm using embedded Tomcat servers,
which looks like this
Tomcat tomcat = new Tomcat()
I'm creating an embedded tomcat server here.
Problem statement
whenever there's an error it displays information on which tomcat version i'm using,
how to hide this in java?
i have a little idea that i need to override ServerInfo.properties, but how do i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定如何在Java中执行此操作,但是如果您使用任何构建脚本(例如Ant / gradle)来进行分配目的,我们可以编写一个任务来覆盖 /硬化JAR文件,并替换 serverInfo。属性文件,具有自定义值的内容。
ANT构建脚本的代码看起来像
,在Gradle中,
请确保您在SRC目录下使用了与您在Include语句中提到的相同路径中的修改后的properties文件。
I'm not sure how we can do this in java, but if you are using any build scripts like ant / gradle for distribution purpose, we can write a task to override / harden the jar file, and replace the ServerInfo.properties file with the customized value whatever we need.
the code for ant build scripts would look like
and in gradle
make sure you have the modified ServerInfo.properties file under src directory in the same path as you have mentioned in the include statement.