jiasudu1649 发表于 2013-1-14 23:08:32

在Eclipse中 Debugging OFBiz

jiasudu Translation

OFBiz Eclipse - Debugging OFBiz
初步设定
如果你还没有把ofbiz导入Eclipse, 请先把 ofbiz 导入(import) Eclipse 。操作如下 File > Import > "Existing Projects into Workspace". 注意项目名称和他在在.project文件中的名称必须是相同的。

下一步是使Eclipse能正确识别你的.xml和.ftl ,以及. bsh等文件。首先,安装一个XML编辑器比如免费的XMLBuddy. 然后, 安装 Freemarker的 Eclipse插件. 最后, 到 Windows > Preferences > General > Editors > File Associations 点击 add "*.bsh" 并且在 Associate editor. 添加他使用Scrapbook。

你也可以设置你的编辑环境符合OFBiz 编码规范. 点Java 文件, 到 Windows > Preferences > Java > Code Style > Formatter and create a new profile. 设置您的制表符为4个空格. 同时, 到 Windows > Preferences > XMLBuddy > Formatting 并选中 "Use spaces for tabs", 或者也是这样配置你的 XMLZ editor.

在 Eclipse 切换"Java Perspective" , "Java Browsing" 和 "Resources"。这样你可以很清楚地浏览代码和浏览目录/文件. 如果你有新的组件,将它们作为<classpathentry> 添加到.classpath 中; 这样在 Java 视图中看到他们。

Java Debugging with Eclipse
在 Eclipse的工具栏,点击绿色的 bug 按钮, 或者点击最顶部 "Run", 然后选 "Debug". 接着点击 "Java Application", 右键点 "New" 创建一个新的configuration 。
http://www.opensourcestrategies.com/images/eclipse1.png

选择start类名. 然后点 "Apply" 和 "Close".
http://www.opensourcestrategies.com/images/eclipse2.png

现在你需要改正Eclipse找到所有的problems(看底部的problems表格内 ):
http://www.opensourcestrategies.com/images/eclipse3.png

最常见的问题, 在build classpath找不到class和libraries,需要你添加 Project > Properties > Java Build Path:
http://www.opensourcestrategies.com/images/eclipse4.png
http://www.opensourcestrategies.com/images/eclipse5.png

你也可以通过编辑在eclipse/workspace/ofbiz的.classpath和增加 <classpathentry excluding="org/ofbiz/securityext/thirdparty/truition/*" kind="src" path="applications/securityext/src"/>排除第三方的 source file 引起的错误

你必须添加 OFBiz base/config 路径到你的 class path. 点 Project > Properties > Java Build Path > Libraries > 和增加 base/config 路径:
http://www.opensourcestrategies.com/images/eclipse6.png

添加 base/config后:
http://www.opensourcestrategies.com/images/eclipse7.png
现在你需要添加你的 JDBC library JARs 到 Eclipse classpath. 点 Project > Properties > Java Build Path > Libraries > 和从 ofbiz/framework/entity/lib/jdbc 选择JARs . 这样, 我们添加了嵌入式derby数据库的所有 JARs文件
http://www.opensourcestrategies.com/images/eclipse8.png

你也需要从ofbiz/framework/catalina/lib为Tomcat添加所有的 JARs 文件 。 注意: 新版本的OFBiz需要更多的JAR文件比这个图中的。添加所有JAR文件。
http://www.opensourcestrategies.com/images/eclipse9.png

为了编译JSP,你可能需要这个:
http://www.opensourcestrategies.com/images/eclipse10.png

现在编辑 base/config/ofbiz-containers.xml和 comment out both the rmi-dispatcher 和 rmi-print-server (这里没有显示):
http://www.opensourcestrategies.com/images/eclipse11.png

现在 OFBiz 应该可以在 Eclipse中运行了. 这里有一些图片是 在 Eclipse 中debugging OFBiz的:
http://www.opensourcestrategies.com/images/eclipse12.png
http://www.opensourcestrategies.com/images/eclipse13.png
http://www.opensourcestrategies.com/images/eclipse14.png
http://www.opensourcestrategies.com/images/eclipse15.png

   
杂记
当你更新你的 code 从 $ svn update的时候, Eclipse 并不知道那些新文件是可用的. 因此, 你可能会有 build 问题. 选中一个文件 > 在 Eclipse 刷新 ,使它是最新的。

确定 ofbiz/ 不在你的Project > Properties > Java Build Path > Source. 仅仅有 ofbiz/applications/.., ofbiz/framework/.., ofbiz/hot-deploy/.. 这些目录在这里, 或者你将得到一个 error:

Cannot nest output folder "hot-deploy/crmsfa/src" inside "ofbiz/"






© 2005-2007 Open Source Strategies, Inc. All rights reserved.
http://www.agoit.com/bbs/
页: [1]
查看完整版本: 在Eclipse中 Debugging OFBiz