首页 > 代码库 > OFBiz进阶之环境搭建(eclipse)

OFBiz进阶之环境搭建(eclipse)

一、 环境准备

1. jdk1.6

下载地址:http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR

2. eclipse

下载地址:

3. mysql

4. navicat for mysql

5. tomcat

二、 环境搭建

1. 配置jdk,配置环境变量

2. 配置tomcat

3. 安装mysql数据库

    建立数据库ofbiz,新建用户ofbiz和密码ofbiz,并且赋予ofbiz全部权限。

4. 下载ofbiz源代码

    下载地址:http://apache.dataguru.cn/ofbiz/apache-ofbiz-12.04.05.zip

5. 配置eclipse

    打开eclipse,并导入ofbiz项目。

三、初始化ofbiz

1. 改用mysql数据库配置

Ofbiz自带的数据库是Derby,Derby是测试系统的数据库,不适合开发用。

 

    1.1 更新JDBC驱动,将mysql的jdbc驱动拷贝到${Ofbiz_Home}\framework\entity\lib\jdbc 目录下。

    1.2 修改${Ofbiz_Home}\framework\entity\config下的entityengine.xml,如下:

          把所有的delagator 的mysql的注释去掉,然后把相应的derby的设置注释掉。

    <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>
View Code

          修改mysql数据库源信息,注意修改数据库基本配置信息、字符集、连接数等。

    <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/ofbiz?autoReconnect=true"                jdbc-username="ofbiz"                jdbc-password="ofbiz"                isolation-level="ReadCommitted"                pool-minsize="2"                pool-maxsize="50"                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/ofbizolap?autoReconnect=true"                jdbc-username="ofbiz"                jdbc-password="ofbiz"                isolation-level="ReadCommitted"                pool-minsize="2"                pool-maxsize="50"                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"                jdbc-uri="jdbc:mysql://127.0.0.1/ofbiztenant?autoReconnect=true"                jdbc-username="ofbiz"                jdbc-password="ofbiz"                isolation-level="ReadCommitted"                pool-minsize="2"                pool-maxsize="50"                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="odbcmysql"            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"/>        <inline-jdbc                jdbc-driver="com.mysql.jdbc.Driver"                jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz_odbc?autoReconnect=true"                jdbc-username="ofbiz"                jdbc-password="ofbiz"                isolation-level="ReadCommitted"                pool-minsize="2"                pool-maxsize="50"                time-between-eviction-runs-millis="600000"/>        <!-- <jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/> -->    </datasource>
View Code

2. 运行ofbiz

    2.1 安装OFBIZ演示数据

ant load-demo

    2.2 启动ofbiz

ant start

    2.3 测试

http://localhost:8080/ecommerce

https://localhost:8443/webtools或者http://localhost:8080/webtools

OFBiz进阶之环境搭建(eclipse)