Windows下如何用特定的server.xml启动Tomcat? [英] How to start Tomcat with a specific server.xml under Windows?

查看:33
本文介绍了Windows下如何用特定的server.xml启动Tomcat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我想以特殊配置启动 Tomcat 6,而不是使用server.xml".所以我创建了另一个名为 server_test.xml 的 xml 文件.现在我想告诉tomcat使用这个配置.这是怎么做的?

I want to start Tomcat 6 with special configuration sometimes, not using the "server.xml". So I created another xml file named server_test.xml. Now I want to tell tomcat to use this configuration. How is this done?

我在网上几乎找不到任何东西.只有这样:在Tomcat配置中使用不同的server.xml文件:./tomcat.sh start -f/var/tmp/server-${USER}.xml"

I found nearly nothing searching the web. Only that: "Use different server.xml file in Tomcat configuration: ./tomcat.sh start -f /var/tmp/server-${USER}.xml"

这正是我想要的.也许这适用于 linux 系统,但不适用于 Windows.有什么想法吗?

This is exactly what I want. Maybe this is working for linux systems but not for windows. Any ideas out there?

推荐答案

我知道了.我带了我半夜,但它有效:)

I've got it. I took me the half night, but it works :)

一开始我也想到了符号链接,但在 Windows 下它不是你想使用的东西.我的第二个想法是修改 catalina.bat,但这并不容易.而不同的 CATALINA_HOME 并不是我真正想要的.

At first I also thought of symbolic links, but under Windows it's not a thing you would like to use. My second thought was modifying catalina.bat, but that's not that easy. And different CATALINA_HOME's is not what I really want.

那我做了什么?我已将 server.xml 作为参数提供给 catalina.bat.

So what have I done? I've provided the server.xml as a parameter to catalina.bat.

catalina.bat start -config \conf\server_test.xml

又好又容易:)

您可以拥有很多服务器配置文件,并提供启动和停止脚本所需的文件.棘手的是 Catalina 类为您提供了错误的使用信息:

You can have a lot of server configuration files and provide the one you need to the start and stop script. The tricky thing was that the Catalina class gives you the wrong usage information :

usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { start | stop }

但是如果您交换参数并首先提供start"或stop",然后提供-config ..."论证,一切正常.

But if you exchange the parameters and first provide "start" or "stop" and then the "-config ..." argument, everything works.

也很不错的是,您可以使用此解决方案在 IntelliJ IDEA 中创建不同的运行配置.我有一个 Tomcat 连接到本地数据库和一个连接到开发数据库的地方.对于每个我有一个不同的 server.xml.

Also very nice is that you can use this solution the create different run configuration in IntelliJ IDEA. I have one where the Tomcat connects to a local database and one connecting to a development database. For each I have a different server.xml.

我希望这会有所帮助.

问候,塞巴斯蒂安

这篇关于Windows下如何用特定的server.xml启动Tomcat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆