简体   繁体   English

Java Web 项目未正确构建

[英]Java Web Project not building correctly

I've got a Java Web Project which I'm deploying to a Tomcat embedded in Eclipse's Servers Plugin, alas, when I navigate to the location of that webapp after publishing/starting the server, the .class files are all missing.我有一个 Java Web 项目,我将它部署到嵌入在 Eclipse 服务器插件中的 Tomcat,唉,当我在发布/启动服务器后导航到该 web 应用程序的位置时,.class 文件都丢失了。 I can navigate as far as ProjectName\\WEB-INF\\classes\\path\\to\\packages\\ -> All packages are empty.我可以导航到 ProjectName\\WEB-INF\\classes\\path\\to\\packages\\ -> 所有包都是空的。

Any Idea how to solve this problem?任何想法如何解决这个问题?

Edit编辑

Build Automatically is checked and it compiles just fine for another web project I've just included, just not for the one specified Build Automatically 被选中,它为我刚刚包含的另一个 web 项目编译得很好,只是不适用于指定的

Edit 2编辑 2

Reinstalled Eclipse (because why not) - nothing's changed, works for Project #2, doesn't work for Project #1.重新安装 Eclipse(因为为什么不) - 没有任何改变,适用于项目 #2,不适用于项目 #1。 Not even the path to the packages is existant now.现在甚至不存在包的路径。 The content of the src folder (that's supposed to be moved to WEB-INF/classes) isn't there at all - but the resources (I've got a resources folder with the same deployment assembly command) are. src 文件夹的内容(应该移动到 WEB-INF/classes)根本不存在 - 但资源(我有一个具有相同部署程序集命令的资源文件夹)是。

A few steps to perform to restore sanity...执行几个步骤以恢复理智......

  1. Refresh your project.刷新您的项目。 It is possible that something was modified on the file system external to Eclipse.可能在 Eclipse 外部的文件系统上修改了某些内容。

  2. Kick of Project -> Clean.项目启动 -> 清洁。

  3. Now look at your project (not the deployed location) on the file system.现在查看文件系统上的项目(不是部署位置)。 Do you see the expected files in the /bin directory (or whatever you may have changed class output directory to)?您是否在 /bin 目录(或您可能已将类输出目录更改为的任何内容)中看到预期的文件?

  4. Let's now try exporting a war using the wizard.现在让我们尝试使用向导导出战争。 File -> Export -> Web -> WAR or something like that.文件 -> 导出 -> Web -> WAR 或类似的东西。 Check the WAR contents.检查 WAR 内容。 Are you .class files there?你那里有 .class 文件吗?

  5. If everything is good so far, there is nothing wrong with your project.如果到目前为止一切都很好,那么您的项目就没有问题。 The Tomcat server adapter just got confused. Tomcat 服务器适配器刚刚被搞糊涂了。

  6. In the Servers view... Make sure Tomcat is running.在服务器视图中... 确保 Tomcat 正在运行。 Next right click on Tomcat and select add/remove projects.接下来右键单击Tomcat并选择添加/删除项目。 Remove your project.删除您的项目。 Confirm that your web app is no longer accessible.确认您的网络应用不再可访问。

  7. Now re-add your project via add/remove projects or invoke one of the run as actions.现在通过添加/删除项目或调用运行作为操作之一重新添加您的项目。

The above should reset Tomcat server adapter and hopefully things should work as expected.以上应该重置Tomcat服务器适配器,希望事情应该按预期工作。

Check if you had deleted or moved your external JARs associated with the project on your IDE.检查您是否删除或移动了与 IDE 上的项目关联的外部 JAR。 I had moved it and ran into the same issue.我已经移动了它并遇到了同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM