在 intellij IDEA 社区版中将 Tomcat 作为应用程序运行
我正在尝试在 intellij IDEA 中设置一个旧网站。我有旧项目的所有源代码和必要的配置文件。在 intellij 中设置源代码和网页内容并进行编译。但我真的不知道如何启动该应用程序。我找到了 post 描述了如何使用 Tomcat 中的“引导类”来执行此操作。我可以使用这种技术启动我的服务器,但我的应用程序不会自动部署在 Tomcat 中。
有没有一种方法可以在使用引导类启动 Tomcat 时指定动态 webapp-directory 之类的内容?我知道我可以配置 Tomcat 在我的项目的 webcontent 文件夹中查找应用程序,但这似乎是错误的方法,例如,如果我更改项目的位置,它将无法工作。
所以我的问题是:有没有办法告诉引导类“包含”我的 Web 应用程序根目录,它是驻留在我的项目文件夹中的 Web 内容文件夹。
I'm trying to setup an old website in intellij IDEA. I have all the source code and necessary configuration files for the old project. Have setup source code and web content in intellij and it compiles. I can't really figure out how to start the application though. I found a post describing how to do this using the "bootstrap class" in Tomcat. I can start my server using this technique but my application is not deployed automatically inside Tomcat.
Is there a way I can specify something like a dynamic webapp-directory when starting Tomcat using the bootstrap class? I know I can configure Tomcat to look for an application in the webcontent folder of my project but that kind of seems like the wrong way to go, eg if I change the location of my project, it wont work.
So my question is: Is there a way I can tell the bootstrap class to "include" my web application root directory, which would be the web content folder residing inside my project folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以使用 server.xml 文件中的上下文(您可以在 tomcat/conf 中找到它)
将这样的行作为子行添加到 server.xml 中的 Host 标记中:
如果您使用 war
或者
如果想使用扩展版本。
这基本上告诉 Tomcat 从该文件夹而不是默认的 webapps 文件夹中获取“myapp”应用程序。
Yes, you can use the context in server.xml file (you find it in tomcat/conf)
Add a line like this as child to the Host tag in server.xml:
if you use a war
OR
if would like to use the expanded version.
This basically tells Tomcat to take the "myapp" application from that folder rather than the default webapps folder.