ofbiz入门及安装

来源:互联网 发布:巨人网络回归a股 编辑:程序博客网 时间:2024/05/10 16:15
1.Ofbiz 介绍:  Ofbiz(http://ofbiz.apache.org) 是 apache 的电子商务平台,充分利用了apache下的Open Source 项目,像 Tomcat, Ant, BeanShell, Jboss 等,构建了一个强大的系统平台,Ofbiz 已经完成了电子商务平台都需要的功能,像用户认证、工作流、交易规则处理等,Ofbiz 的核心技术在于 Entity Engine,其他的组件基本都是基于它的。简单来说 Entity Engine 的主要功能是将数据库表创建、对象与数据表的映射、对象的查询等做了强大封装,你可以在一个简单的 XML 文件中定义数据库表结构,Ofbiz 会自动帮你在数据库建表,并动态生成映射对象,你在程序中可以只考虑对 Object 的处理,Ofbiz 会自动通过事务逻辑更新到数据库中。Ofbiz 宣称的优点之一是用很少的 Code 完成复杂的处理。 
2.Ofbiz 下载与安装  首先要安装 J2SDK1.6,到 http://java.sun.com 上下载,安装后设定 JAVA_HOME 环境变量为 J2SDK 的安装目录。  访问网站http://ofbiz.apache.org,上面有下载的连接,请选择对应最新的稳定版本,下载下来解开后就可以运行了。 

3.ofbiz 配置mysql数据库
首先在 MySQL 创建数据库 ofbiz。
更新JDBC驱动,将mysql的jdbc驱动copy到${ofbiz-install-dir}/framework/entity/lib/jdbc 目录下。
设置实体引擎( Entity Engine)的缺省数据库为mysql.在修改 ${ofbiz install dir}/framework/entity/config/entityengine.xml文件中修改配置:
修改数据库连接参数:
<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://localhost:3306/ofbiz?autoReconnect=true"  --数据库名 
                jdbc-username="root"  --用户名 
                jdbc-password=""   --密码 
                isolation-level="ReadCommitted" 
                pool-minsize="2" 
                pool-maxsize="250" 
                time-between-eviction-runs-millis="600000"/><!-- ####--> 
        <!-- <jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/> --> 
    </datasource>

修改实体引擎的数据库缺省配置如下:将datasource-name的值设置为 localmysql: 
<!-- the connection factory class to use, one is needed for obtaining connections/pools for defined resources --> 
    <connection-factory class="org.ofbiz.entity.connection.DBCPConnectionFactory"/> 

    <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"/> 
    </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"/> 
    </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"/> 
    </delegator> 
    
            <delegator name="other" 
               entity-model-reader="main" 
               entity-group-reader="main" 
               entity-eca-reader="main"> 
        <group-map group-name="org.ofbiz" 
                  datasource-name="localmysql"/> 
    </delegator>

4.ofbiz编译和运行
打开dos并在ofbiz9 目录下执行命令: 
ant run-install (该命令用来预置默认数据库,编译java code)
startofbiz.bat

启动成功,可以打开以下界面: 
http://localhost:8080/ecommerce; 
https://localhost:8443/webtools; 

<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击