Unix 中的 Web 服务。目录结构应该是什么样的
我之前使用 Eclipse IDE、Tomcat 和 JAX-RS 库在本地主机上创建了一个简单的 RESTful Web 服务。
我现在尝试将其移动到安装了 Tomcat 的不同 UNIX 服务器上。我不知道如何开始,就像在 Eclipse 中创建一个“动态 Web 项目”一样。我是否需要自己创建一个目录,其中包含 Eclipse 创建的所有子目录?该目录是否应该放置在 Tomcat 容器中的 webapps 文件夹中。 META-INF和WEB-INF也应该是我自己创建的吗?
我应该把 Java 类放在哪里?
有人可以澄清这一点或指导我查看有关相同内容的任何文档吗?
I earlier got to create a simple RESTful webservice on my localhost using Eclipse IDE, Tomcat, and JAX-RS libraries.
I am now trying to move the same on to a different unix server which has Tomcat installed. I am not knowing how to get started as in what is equivalent to creating a "Dynamic Web Project" that I do in Eclipse. Do I need to just create a directory myself with all the sub-directories as created by Eclipse? Should this directory be placed in webapps folder in Tomcat container. Should META-INF and WEB-INF also be created by myself?
Where should I put my Java classes?
Can somebody please clarify this or direct me to any documentation about the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将应用程序打包为 WAR 文件。
Sun Java EE 6 教程 具有 专门用于打包的章节。
这很容易 将 Web 应用程序导出为 Eclipse 中的 war。
You need to package your application in a WAR file.
The Sun Java EE 6 Tutorial has a chapter deciated to packaging.
It's pretty easy to export a web application as a war in Eclipse.
动态Web项目(右键单击)=>导出=> Web =>war 文件 =>war 导出对话框
创建Web 应用程序存档 - WAR 是您问题的解决方案,
但请注意您需要的所有库。
您可以轻松提取(解压缩)WAR 文件内容
并检查您的项目结构和所需的库
它们将位于 WAR 的 WEB-INF/lib 中。
确保两个 Tomcat 的设置方式相同,
确保您的代码对所有操作系统友好(用户、文件路径、权限)
始终编写一些将在应用程序启动时运行的测试简单代码,
并检查所有依赖项和库、系统时钟、外部网络通信,以便您可以在 Web 应用程序控制台或记录器中轻松跟踪它。
问候
Dynamic Web Project (right click) => Export => Web =>war file =>war export dialog
Creation of web application archive - WAR is the solution for your problem,
but take care about all libraries that you need there.
You can easily extract (unzip) WAR file content
and check your project structure and libraries needed
and they will be in WAR's WEB-INF/lib.
Make sure that both Tomcats are set same way,
make sure your code is all OS friendly (users, file paths, permissions)
Always write some test simple code that will run up on app start,
and check all dependencies and libs, system clock, outside world network communication, so you can trace it in web app console or logger easily.
regards