将Apache OFBiz从Derby迁移到MySQL

时间:2017-04-18 20:25:20

标签: mysql derby ofbiz

我尝试使用this tutorial将Apache OFBiz从derby迁移到mysql。在entityengine.xml进行更改之前,我使用defaultData执行了ofbiz,并将数据从webtools导出到xml文件中。之后,我做了所有上述更改,创建了工作的db模式和用户。但是当我在这些更改后运行ofbiz时,我收到了一条带有消息的例外

`invalid delegator name!`

为什么?我目前正在使用16.011版本的OFBiz。以下是我的委托人和数据源的样子

<datasource name="localmysql"
            helper-class="org.apache.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="latin1"
            collate="latin1_general_cs">
        <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"/>
        <read-data reader-name="ext-test"/>
        <read-data reader-name="ext-demo"/>
        <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="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="latin1"
            collate="latin1_general_cs">
        <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="ofbizolap"
                jdbc-password="ofbizolap"
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="250"
                time-between-eviction-runs-millis="600000"/>
    </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="latin1"
            collate="latin1_general_cs">
        <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="ofbiztenant"
                jdbc-password="ofbiztenant"
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="250"
                time-between-eviction-runs-millis="600000"/>
    </datasource>

和委托人

<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="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </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="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </delegator>

    <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="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </delegator>

2 个答案:

答案 0 :(得分:0)

最近改变了Apache OFBiz包结构,提到的tuturial并不完全是最新的。我改变了“org.ofbiz”。条目“org.apache.ofbiz”。在教程中。

请再试一次并报告现在是否适合您。

答案 1 :(得分:0)

(我使用OFBiz版本16.11.02,此时为最新版本)

为数据库创建用户:

create database ofbiz;
create database ofbizolap;
create database ofbiztenant;
use mysql;
select database();
create user ofbiz@localhost;
create user ofbizolap@localhost;
create user ofbiztenant@localhost;

UPDATE mysql.user
    SET authentication_string = PASSWORD('ofbiz'), password_expired = 'N'
    WHERE User = 'ofbiz' AND Host = 'localhost';
FLUSH PRIVILEGES;

UPDATE mysql.user
    SET authentication_string = PASSWORD('ofbizolap'), password_expired = 'N'
    WHERE User = 'ofbizolap' AND Host = 'localhost';
FLUSH PRIVILEGES;

UPDATE mysql.user
    SET authentication_string = PASSWORD('ofbiztenant'), password_expired = 'N'
    WHERE User = 'ofbiztenant' AND Host = 'localhost';
FLUSH PRIVILEGES;

grant all privileges on *.* to 'ofbiz'@localhost identified by 'ofbiz';
grant all privileges on *.* to 'ofbizolap'@localhost identified by 'ofbizolap';
grant all privileges on *.* to 'ofbiztenant'@localhost identified by 'ofbiztenant';

使用端口号,默认,它是3306

 jdbc-uri="jdbc:mysql://127.0.0.1:3306/ofbiz?autoReconnect=true"

找到单词derby,将其更改为mysql

然后

gradlew cleanAll --info
gradlew loadDefault --info
gradlew ofbiz --info