Tomcat在其他打开的eclipse项目中为类引发ClassNotFound异常 [英] Tomcat throws ClassNotFound exceptions for classes in other open eclipse projects

查看:230
本文介绍了Tomcat在其他打开的eclipse项目中为类引发ClassNotFound异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个eclipse项目结构,看起来像这样:

I have an eclipse project structure that looks something like this:

eclipse
    project a
    project b

所有这些项目都是Maven项目。项目B是一个Eclipse WTP项目,并且包含项目A作为依赖。我正在使用m2eclipse插件。

All of these projects are Maven projects. Project B is an Eclipse WTP project and contains Project A as a dependency. I'm using the m2eclipse plugin.

当我将Project B部署到Tomcat(全部来自Eclipse)时,总是会发出错误,指出它无法从Project A.我可以解决这个问题的唯一方法是在Eclipse中关闭项目A,并执行 mvn install 命令,因此在这一点上,项目A被视为任何其他依赖关系。

When I deploy Project B to Tomcat (all from within Eclipse) it always throws errors saying that it can't find classes from Project A. The only way I can resolve this is to close Project A in Eclipse and do a mvn install command, so at this point Project A is treated like any other dependency.

我不想一直重新打开,然后关闭项目A,每次我进行更改(这在现阶段很频繁)。

I would like to not have to keep reopening and then closing Project A every time I make changes to it (which is pretty frequently at this stage).

我已经尝试将Project A添加到B项目的Build Path,但这似乎并没有办法。再次,它只有在Eclipse中关闭项目时才有效,所以它被视为正常的maven依赖关系。

I have tried adding Project A to Project B's Build Path, however that doesn't seem to do the trick. Again, it only works if I close the project in eclipse so it's treated like a normal maven dependency.

我使用的是Helios版本的Eclipse。项目B是一个Spring项目,当它导入所有豆类时,Tomcat就会自动下载。

FYI I'm using the Helios version of Eclipse. Project B is a Spring project, so naturally Tomcat falls over when it imports all the beans etc.

有没有人有任何建议?感谢很多。

Does anyone have any suggestions? Thanks a lot.

推荐答案

tomcat找不到你的类的原因是在Eclipse中看不到eclipse中的项目依赖关系。要解决问题,您可以将项目a的bin文件夹添加到从项目b运行的应用程序的tomcat类路径。

The reason that tomcat cannot find your classes is that the project dependency in eclipse is not seen by tomcat. To resolve the issue you can add the bin folder of project a to the tomcat classpath of the app running from project b.

这篇关于Tomcat在其他打开的eclipse项目中为类引发ClassNotFound异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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