关于java:如果在eclipse中打开了一个相关项目,则Web项目不会在服务器上运行

Web project doesn't run on server if a dependent project is opened in eclipse

我正在使用Eclipse 4.4.2,Maven和Tomcat v7.0开发一个Web应用程序。该应用程序包含一个

  • AppSuite(<packaging>pom</packaging>)
  • AppModel(<packaging>jar</packaging>,具有一些自动生成的类)
  • AppUserInterface(<packaging>war</packaging>,取决于AppModel)

AppUserInterface和AppModel是AppSuite的模块。

我当前面临的问题是,如果我在Eclipse中打开了所有三个项目,并且尝试在服务器上运行AppUserInterface,则所有内容都会正确移动到tomcat webapps文件夹( AppUserInterface以及所有包含AppModel.jar的库),但tomcat抛出异常

1
java.lang.NoClassDefFoundError: com/app/model/ClassName

但是,如果我在Eclipse中关闭项目AppModel,则在服务器上运行AppUserInterface时,一切运行正常。

我怀疑如果AppUserInterface应该与本地AppModel一起使用,则Eclipse会变得混乱。

有什么想法可以解决此错误,以便我可以同时打开所有三个项目并仍然运行AppUserInterface?

编辑:java.lang.NoClassDefFoundError: com/app/model/ClassName类不是自动生成的类。


添加了赏金,并在2分钟后找到了解决方法...

解决方案是rmtheis的解决方案,在本主题中我直到现在才发现Eclipse中的Strange " java.lang.NoClassDefFoundError "。一个简单的Project->Clean...以某种方式解决了这个问题。