---
title: "OFBIZ开源电子商务学习心得"
author: "danlley"
date: "2007-07-17T13:36:41Z"
tags: []
slug: "ofbiz"
draft: false
lastmod: "2007-07-17T13:36:41Z"
id: 101977
url: "https://danlley.iteye.com/blog/101977"
---

看懂在APACHE网站上的英文文档确实是一项不小的挑战,下面说说飞宇对OFBIZ的入门方法,希望对像飞宇一样刚起步的人有所启示:  
一、获取OFBIZ源码  
由于我们学校用的是教育网，而关于OFBIZ的源码与文档只能由APACHE等外国网站提供，后来在文档上看到可以通过SVN下载，但事实证明在教育网下想通过SVN下载到OFBIZ几百MB的源码是不可能的。  
后来，回家用ADSL，速度奇快，一般两三个小时就完成了。里面有多少个文件没数过，反正是挺多的。  
还有一种不用SVN下载的方法，是直接上网站下。  
PS：  
用SVN下载:  
In the directory where you want OFBiz to be, do a SVN checkout of the ofbiz trunk. For example:  
svn co http://svn.apache.org/repos/asf/ofbiz/trunk ofbiz  
直接从网站下:  
All users can access anonymous WebDAV either by pointing your browser or connecting your WebDAV client to the same address as above:  
http://svn.apache.org/repos/asf/ofbiz/trunk  
推荐看Source Repository and Access这篇文档  
二、运行自带的DEMO  
1、在CMD里面定位到OFBIZ源码的根目录；  
2、运行ant.bat命令  
3、运行ant.bat run-install;  
4、运行ant.bat run;  
5、由于DEMO是用OFBIZ自带的DERBY数据库和J2EE容器，这时CMD窗口会占很大的系统资源，耐心点等到窗口信息停止滚动，不要关它。  
6、打开游览器：  
Open a browser and go to http://127.0.0.1:8080/ecommerce/control/main  
for the ecommerce application or https://127.0.0.1:8443/webtools/control/main  
for the WebTools application or https://127.0.0.1:8443/catalog/control/main  
for the Catalog Manager application.  
PS：在调试时还有一个命令常用：ant.bat clean  
推荐看Demo and Test Setup Guide这篇文章  
三、与MYSQL结合  
1、安装MYSQL，把MYSQL JDBC驱动放在OFBIZ源码ofbiz\\framework\\entity\\lib\\jdbc下；  
2、在MYSQL中创建一个数据库，并赋予完全访问权限，如ofbiz\_mysql数据库；  
3、修改ofbiz\\framework\\entity\\config下的entityengine.xml文件：

xml 代码

1. &lt;delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false"&gt;
2. &lt;group-map group-name="org.ofbiz" datasource-name="localmysql"/&gt;
3. &lt;/delegator&gt;

\----------------------------------------------------------------------

xml 代码

01. &lt;datasource name="localmysql"
02. helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
03. schema-name="ofbiz\_mysql"
04. field-type-name="mysql"
05. check-on-start="true"
06. add-missing-on-start="true"
07. use-pk-constraint-names="false"&gt;
08. &lt;read-data reader-name="seed"/&gt;
09. &lt;read-data reader-name="demo"/&gt;
10. &lt;read-data reader-name="ext"/&gt;
11. &lt;inline-jdbc
12. jdbc-driver="com.mysql.jdbc.Driver"
13. jdbc-uri="jdbc:mysql://127.0.0.1:3306/ofbiz\_mysql?autoReconnect=true"
14. jdbc-username="root"
15. jdbc-password="123456"
16. isolation-level="ReadCommitted"
17. pool-minsize="2"
18. pool-maxsize="20"/&gt;
19. &lt;!-- &lt;jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/&gt; --&gt;
20. &lt;/datasource&gt;

\---------------------------------------------------------------------  
4、按照运行DEMO的方法重新载入，完成转移数据库。  
PS：在MYSQL中可以看到DEMO的数据库已经转移到里面了，几十个表呢，当然里面也有一些初始数据。  
推荐看Demo and Test Setup Guide和Apache OFBiz Technical Production Setup Guide这两篇文章。