一直在用.NET做项目,最近一个项目要用ZK+Spring+Hiberate来完成,于是开始了与Java的第一次亲密接触。因为是第一次,所以在一路的过程中遇到了不少的问题。打算借JavaEye的宝地,在我的Blog中记录下来,供自己以后总结。
今天主要遇到的问题是:我的项目分为前端(A)和后端(B)两个工程,前端工程主要是用ZK实现用户界面,spring secrutiy实现安全机制等。后端主要是用Spring与Hibernate实现主要的业务逻辑和数据的处理。项目开始的前一阶段一直用MyEclipse处理,后来因为种种原因换回了Eclipse,以前直接用MyEclipse自带的Deployment工具将项目部署到Tomcat中,而在Eclipse中我则用WST结合Tomcat进行部署与调试。一开始在B工程中引用工程(Project Reference).编译期间无任何错误。A工程中可以顺利的调用B工程所有的类。但是我用Tomcat调试A工程的时候,在运行时A工程中无法使用B中的类。一直抛出Class Not Find异常。问题应该是出在在运行时,B工程中的类并没有被包括到A的WEB-INF下面去。具体的解决方案是在找到Java EE Module Dependencies,在这个地方把B工程包含进去。
在国外的一个论坛看到一个哥们和我遇到的问题一样。
以下英文原文是搜索到的答案:
J2EE/JEE module dependencies would solve this problem. You have already done the task of extracting your common classes into its own project, possibly because other projects depend on these classes. Either way, you'll have to ensure that this is a Utility project (appears under J2EE/JEE in the project wizards), and not just a plain Java project. One that is done, you can proceed to add the Utility project to your build path (compile-time path) as you have figured out.
The additional (final) step is to establish a J2EE/JEE module dependency between your Dynamic Web project and the shared library, which causes the utility's classes to be placed in WEB-INF\lib during deployment, and even during export of the WAR. To do so, visit the dynamic web project's properties, and browse to the J2EE/JEE module dependencies. Ensure that your utility project is selected here. Redeploy/publish your application and you should be good to go.
------------
接下来的讨论
That seems to have done the trick, but I'm not sure about what you were saying about it being a "Utility" project. Is there something I can see in my .project file or in .settings/ that would let me know it was the right type? – Brian Deacon Nov 28 '08 at 22:12
Utility projects are Java projects, though they are more apt for the J2EE context. They represent your code (not third party JARs) that are shared across multiple projects in your Enterprise App. Usually these are classes used across multiple EJBs and often a single Web module. – Vineet Reynolds Nov 28 '08 at 22:25
I normally do not place Utility projects in plain vanilla Java projects, because Utility projects will have the Server's runtime JARs automatically added to the classpath. For instance I could utilize datasources from the same project without adding the container's JARs to the build path. – Vineet Reynolds Nov 28 '08 at 22:28
And to answer your question about checking the type of the project, you can check the natures of your project in the .project file. For instance, plain Java projects have the org.eclipse.jdt.core.javanature as the only nature in my Ganymede workspace. – Vineet Reynolds Nov 28 '08 at 23:05
Very helpful. Thank you! – Brian Deacon Dec 3 '08 at 23:40
分享到:
相关推荐
Eclipse 新建WEB工程的WebContent目录设置默认WebRoot,和设置编译class默认输出WebRoot\WEB-INF\classes https://blog.csdn.net/love20yh/article/details/81038250
接下来,我们需要编辑项目的设置文件 org.eclipse.wst.common.project.facet.core.xml,以便将 jst.web 的版本更改为 2.5。这个文件位于项目的根目录下的.settings 文件夹中。 Eclipse 中 Web 项目的配置 在 ...
然而,在使用 Eclipse 发布 Web 项目时,可能会遇到一些问题,这篇文章将解决两个常见的问题。 第一个问题是 Eclipse 无法识别 Web 项目。在某些情况下,Eclipse 无法将导入的 Web 项目识别为 Web 项目,从而无法...
本文将深入探讨如何在Eclipse中自动部署Web项目至Tomcat服务器的webapps目录下,这一过程对于提高JavaEE项目的开发效率至关重要。我们将从环境搭建、项目打包与部署、以及Eclipse自动部署配置三个方面进行详细讲解。...
因此,在将Myeclipse中的Web项目迁移到Eclipse时,需要对项目的一些配置进行调整,以适应Eclipse的工作方式。 #### 二、具体步骤 1. **准备阶段**:确保Eclipse已安装并正确配置,包括必要的插件和JDK环境。 2. *...
### Eclipse安装ADT时遇到“org.eclipse.wst.sse.core 0.0.0”问题解析及解决方案 在学习和实践Android开发的过程中,不少初学者可能会遇到在Eclipse中安装ADT(Android Development Tools)插件时出现问题的情况,...
本篇将详细介绍如何使用WST V6.1来构建一个Web工程,并将其部署在Tomcat服务器上。 1. **新建项目**: 首先,打开IBM WebSphere Application Server Toolkit并启动一个新的工作空间。在“文件”菜单中选择“新建”...
本文将深入探讨如何在Eclipse中将一个普通的Java项目转换为Web项目,这对于那些希望利用Java开发Web应用程序的开发者来说至关重要。 ### Eclipse中Java项目转Web项目的步骤详解 #### 步骤一:准备Java项目 首先,...
第二种方法是使用Eclipse的自动部署功能,可以实现Eclipse自动部署项目到Tomcat的webapps目录下,而不是到工作区下的.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps。这种方法可以实现每修改下源...
1、找到eclipse插件文件plugins 类似org.eclipse.wst.jsdt.core_version.jar备份 2、把此文件覆盖插件文件plugins原来的文件。 3、删除工作空间下文件:workspace/.metadata/.plugins/org.eclipse.wst.jsdt.core 4、...
1. **检查已安装插件**:首先,进入Eclipse的“帮助”(Help) -> “关于Eclipse IDE”(About Eclipse IDE) -> "安装详细信息" (Installation Details),在"插件" (Plugins) 栏目中查找`org.eclipse.wst.sse.ui`。...
wst eclipse插件 org.eclipse.wst.javascript.ui org.eclipse.wst.sse.ui eclipse
在本文中,我们将详细探讨如何使用Eclipse IDE(集成开发环境)来部署Web项目,特别是针对Jdk1.6.0、Tomcat6.0版本的配置和操作步骤。Eclipse Helios 3.6.1是推荐使用的版本,因为它在性能上优于3.6.2。 首先,确保...
在IT行业中,开发Java Web应用程序时,经常使用集成开发环境(IDE)如Eclipse进行编码。然而,每次修改代码后都需要重启服务器以查看更改效果,这无疑降低了开发效率。为了解决这个问题,开发者通常寻求“热部署”...
wst eclipse插件 org.eclipse.wst.javascript.ui org.eclipse.wst.sse.ui eclipse
wst eclipse插件 org.eclipse.wst.javascript.ui org.eclipse.wst.sse.ui eclipse
wst eclipse插件 org.eclipse.wst.javascript.ui org.eclipse.wst.sse.ui eclipse
通过以上步骤,您可以成功地将MyEclipse中的项目转换为Eclipse项目,并解决了Web工程在不同IDE间的兼容性问题。需要注意的是,在转换过程中,确保遵循每一步的操作细节,特别是在修改`.project`文件时,要仔细核对每...
解决方法是:在 Eclipse 安装文件里面的 .setting 文件里面的 org.eclipse.wst.common.project.facet.core.xml 文件,修改 <installed facet="jst.web" version="3.0"/> 为 <installed facet="jst.web" version="2.5...
本文将指导您如何将外部的 JSP + Servlet 项目导入 Eclipse 中,并解决一些可能遇到的问题。 将外部项目导入 Eclipse 首先,需要确保 Eclipse 是 Java EE 版本的,或者已经安装了 WTP 插件。然后,修改 Eclipse ...