初识ofbiz12.04(一)

来源:互联网 发布:个人收徒网站源码 编辑:程序博客网 时间:2024/05/16 18:53

注:机器环境:win8.1 JDK1.7.1_17  MySQL:5.5.41-0ubuntu0.14.04.1

1、什么是ofbiz?

    OFBiz是一个非常著名的电子商务平台,OFBiz 已经正式成为 Apache 的顶级项目: Apache OFBiz。虽然是著名的电子商务系统,但是其功能不仅仅包含了电子商务功能,还包括了企业内部人员管理、库存管理等等功能。

    ofbiz虽然很好用,但是由于其框架太大,而且涉及到的技术有20+种,所以令很多人望而却步,但是如果能够真的学习好该项目,对自己的开发将会是事半功倍的效果。

2、下载并运行ofbiz

    因为ofbiz是基于Java开发,所以在运行ofbiz之前需要配置JDK的环境(注意是JDK的环境,而不是JRE环境,因为该系统需要进行源码的编译),不需要配置任何服务器和数据库环境,因为ofbiz内置了服务器和数据库,其中内置的服务器是Tomcat,内置的数据库是Derby

    官方下载网址:http://ofbiz.apache.org/download.html(现在最新版本是13.07,但是因为12.04学习资料最多,所以自己选了12.04)

    运行:将下载的源码解压到任何目录,然后进入根目录,打开CMD,直接输入命令 ant load-demo start(linux下命令为./ant load-demo start)即可

    因为需要进行源码的编译,所以输入命令后运行时间比较长(根据机器配置不同,所需时间略有差异),大概等待10min+即可完成编译。

    然后在浏览器输入以后网址即可浏览ofbiz:

    1).后台管理界面:http://localhost:8080/catalog/  (登录名: admin  密码:ofbiz)

    2).前台界面:http://localhost:8080/ecommerce

    然后就可以浏览ofbiz,然后自己可以先尝试对ofbiz进行操作,具体的讲解将会在下面文章讲述

  (PS:不得不吐槽下ofbiz的界面,我都被他丑哭了,~~~~(>_<)~~~~ ,但是我坚持认为这是中美之间的文化差异,所以心里也就接受了)

3、解决ofbiz服务器端口占用问题

    如果你的机器上8080、8443端口被占用的话,那么程序将会启动失败,那么我们就需要修改ofbiz服务器默认的端口

    1).修改framework\base\config\ofbiz-containers.xml文件

          190行修改8080为想要的端口,例如58080

          228行修改8443为想要的端口,例如58443

    2).修改framework\webapp\config\url.properties文件

      修改port.https=58443    port.http=58080【与ofbiz-containers.xml中193行和231行修改的端口保持一致】

    然后重启输入地址浏览即可:

         a).后台管理界面:http://localhost:58080/catalog/  (登录名: admin  密码:ofbiz)

         b).前台界面:http://localhost:58080/ecommerce

4、DB使用MySQL

      进入到 framework/entity/config 目录下打开 entityengine.xml

    1).注释掉derby数据库信息,打开Mysql的注释

     

    <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="localderby"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/> -->        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>         <!-- <group-map group-name="org.ofbiz" datasource-name="localpostnew"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/> -->    </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="localderby"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/> -->        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>         <!-- <group-map group-name="org.ofbiz" datasource-name="localpostnew"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/>  -->    </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="localderby"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/> -->        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>         <!-- <group-map group-name="org.ofbiz" datasource-name="localpostnew"/>        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap"/>        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/>  -->    </delegator>

    2)找到datasource name="localmysql"处如下修改:

   

 <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="tenant"/>        <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:3306/ofbiz?autoReconnect=true&amp;useUnicode=true&characterEncoding=UTF-8"                jdbc-username="root"                jdbc-password="ofbiz"                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>    <datasource name="localmysqlolap"            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="tenant"/>        <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:3306/ofbizolap?autoReconnect=true&amp;useUnicode=true&characterEncoding=UTF-8"                jdbc-username="root"                jdbc-password="ofbiz"                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>    <datasource name="localmysqltenant"            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="tenant"/>        <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"<datasource name="localmysqltenant"            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="tenant"/>        <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:3306/ofbiztenant?autoReconnect=true&amp;amp;useUnicode=true&amp;characterEncoding=UTF-8"                jdbc-username="root"                jdbc-password="ofbiz"                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>

    修改地方已经标出:character-set、collate、jdbc-url、jdbc-username、jdbc-password【数据库的用户名和密码按自己连接写】

      3).在自己的数据库中创建三个数据库分别为ofbiz、ofbizolap、ofbiztenant

      4).将JDBC驱动放到framework/entity/lib/jdbc目录下  【驱动:http://pan.baidu.com/s/1i304d61】

    然后启动ofbiz,因为需要建表,所以等待时间稍微久一点,完成之后就开一在数据库ofbiz中看到800+张表建立成功,然后访问http://localhost:58080/ecommerce即可



         

0 0
原创粉丝点击