如何在 tomcat 中设置同时在 eclipse 和使用 startup.bat 中工作的 JVM 参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13870225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:27:51  来源:igfitidea点击:

How to set JVM arguments in tomcat that work both in eclipse and using the startup.bat

eclipsetomcattomcat7eclipse-wtp

提问by Noremac

I have an installation of Tomcat 7 on windows to which I am deploying my app. I have a couple of JVM args that I need set for the applications running on the server. In searching around on the web I find two (three if you count the windows service) camps:

我在将应用程序部署到的 Windows 上安装了 Tomcat 7。我需要为服务器上运行的应用程序设置几个 JVM 参数。在网上搜索时,我找到了两个(如果算上 Windows 服务,则为三个)阵营:

For those using eclipse:

对于那些使用 eclipse 的人:

Double click on the server > Open launch configuration > arguments tab

双击服务器 > 打开启动配置 > 参数选项卡

For those using tomcat's startup script:

对于那些使用 tomcat 的启动脚本的人:

Create a setenv.bat (or setenv.sh for Linux) and set either CATALINA_OPTS or JAVA_OPTS

创建 setenv.bat(或 Linux 的 setenv.sh)并设置 CATALINA_OPTS 或 JAVA_OPTS

However, they seem to be mutually exclusive. Setting the arguments in eclipse (+1 if you can tell where these are stored) don't affect the startup script and setting the setenv.bat properties don't affect the server when started within eclipse. Both work individually.

然而,它们似乎是相互排斥的。在 eclipse 中设置参数(如果你能知道这些参数的存储位置,则为 +1)不会影响启动脚本,并且在 eclipse 中启动时设置 setenv.bat 属性不会影响服务器。两者都单独工作。

Both point to the same installation, and in eclipse on the overview page of the server, I have selected "Use Tomcat installation (takes control of Tomcat installation).

两者都指向同一个安装,并且在eclipse服务器的概览页面上,我选择了“使用Tomcat安装(控制Tomcat安装)”。

采纳答案by Noremac

As I mentioned in the comment above, it looks like the WTP plugins do not call the startup scripts, but directly call on Tomcat through the java executable. Therefore, the VM arguments from eclipse are put directly on the command line, not stored in some config file such as setenv.bat, neither does it read from such a config file from startup. Therefore the two are completely separate in configuration.

正如我在上面的评论中提到的,看起来 WTP 插件不调用启动脚本,而是通过 java 可执行文件直接调用 Tomcat。因此,来自 eclipse 的 VM 参数直接放在命令行上,而不是存储在某些配置文件中,例如 setenv.bat,它也不会从启动时从此类配置文件中读取。因此两者在配置上是完全分开的。