开源框架OFBiz研究

Apache OFBiz是一个非常著名的电子商务平台,是一个非常著名的开源项目,提供了创建基于最新J2EE/XML规范和技术标准,构建大中型企业级、跨平台、跨数据库、跨应用服务器的多层、分布式电子商务类WEB应用系统的框架。 OFBiz最主要的特点是OFBiz提供了一整套的开发基于Java的web应用程序的组件和工具。包括实体引擎, 服务引擎, 消息引擎, 工作流引擎, 规则引擎等。

准备工作:

1:安装 JDK 1.6

2:安装 MySQL

3:  安装ant

4: 从apache官网下载apache-ofbiz-10.04,解压到任意目录,改为ofbiz(我放在myeclipse工作空间,方便导入)。并在mysql创建数据库名为ofbiz

5: 编辑D:\Workspaces\ofbiz\framework\entity\config下的entityengine.xml

注意只需要更改红色标记的配置

 <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysql "/>
    </delegator>
    <delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysql "/>
    </delegator>

    <!-- be sure that your default delegator (or the one you use) uses the same datasource for test. You must run "ant run-install" before running "ant run-tests" -->
    <delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
        <group-map group-name="org.ofbiz" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysql "/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysql "/>
    </delegator>

 

<datasource name="localmysql"
            helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
            field-type-name="mysql"
            check-on-start="true"
            add-missing-on-start="true"
            check-pks-on-start="false"
            use-foreign-keys="true"
            join-style="ansi-no-parenthesis"
            alias-view-columns="false"
            drop-fk-use-foreign-key-keyword="true"
            table-type="InnoDB"
            character-set="utf8"
            collate="utf8_general_ci">
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <inline-jdbc
                jdbc-driver="com.mysql.jdbc.Driver"
                jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true "
                jdbc-username="root "
                jdbc-password="123 "
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="250"
                time-between-eviction-runs-millis="600000"/><!-- Please note that at least one person has experienced a problem with this value with MySQL
                and had to set it to -1 in order to avoid this issue.
                For more look at http://markmail.org/thread/5sivpykv7xkl66px and http://commons.apache.org/dbcp/configuration.html-->
        <!-- <jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/> -->
    </datasource>

6:把mysql驱动jar包copy到D:\Workspaces\ofbiz\framework\entity\lib\下

7: 这个问题要注意

在5.1以及之前版本的MySQL中新建一个Table,可以这样执行:

CREATE TABLE t (i INT) TYPE = MYISAM;

或者

CREATE TABLE t (i INT) ENGINE = MYISAM;

在MySQL5.5版本中,用TYPE来指定存储引擎已经行不通,标准用法是ENGINE。

因此要修改ofBiz ,ofbiz\framework\entity\src\org\ofbiz\entity\jdbc\DatabaseUtil.java  这个工具类生成的建表SQL,是用TYPE = 的。修改 DatabaseUtil.java 类即可(找到createTable方法把 if (UtilValidate.isNotEmpty(this.datasourceInfo.tableType)) {
            sqlBuf.append(" ENGINE ");type改为
ENGINE
            sqlBuf.append(this.datasourceInfo.tableType);
        })或者的话无法初始化数据库

8:进入到ofbiz根目录下,使用ant命令执行:ant run-install (大约16~20分钟)出现

 BUILD SUCCESSFUL
Total time: 16 minutes 48 seconds  表示初始化成功

9:导入myeclipse(import...)

启动 ofbiz:

有两种方式可以启动 ofbiz:

1、 双击根目录下的 startofbiz.bat启动

2、 在 myeclipse中用鼠标右键点击 build.xml,在右键菜单中选择 Run As->Ant Build…在弹出的构建对话框中 targets选项卡中勾选 run后点击 run,这样ok啦

访问 ofbiz:

输入 https://127.0.0.1:8443/webtools/control/main就可以进入后台管理页面了,页面上直接有提示,默认的账户名是admin,密码是ofbiz。

http://localhost:8080/ecommerce/control/main网上商城

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值