1.添加p6spy-2.0-SNAPSHOT.jar到runtime\lib下。
2.runtime\classes下添加spy.properties文件,修改47-49
# mysql Connector/J driver
realdriver=com.mysql.jdbc.Driver 去掉此行前的注释
3.runtime\conf\MoquiProductionConf.xml重定义mysql的连接信息
修改driver为"com.p6spy.engine.spy.P6SpyDriver",改后如下:
<database-list>
<database name="mysql" join-style="ansi-no-parenthesis" offset-style="limit"
table-engine="InnoDB" character-set="utf8" collate="utf8_general_ci"
default-isolation-level="ReadCommitted" default-jdbc-driver="com.p6spy.engine.spy.P6SpyDriver"
default-test-query="SELECT 1">
</database>
</database-list>
4.runtime\conf\MoquiProductionConf.xml 中定义mysql数据源
<entity-facade crypt-pass="MoquiProductionDefaultPassword:CHANGEME">
<datasource group-name="transactional" database-conf-name="mysql" check-pks-on-start="true" schema-name="">
<inline-jdbc jdbc-uri="jdbc:mysql://127.0.0.1:3307/moquitransactional?autoReconnect=true&characterEncoding=UTF-8"
jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2"
pool-maxsize="50" />
</datasource>
<datasource group-name="analytical" database-conf-name="mysql" schema-name="">
<inline-jdbc jdbc-uri="jdbc:mysql://127.0.0.1:3307/moquianalytical?autoReconnect=true&characterEncoding=UTF-8"
jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2"
pool-maxsize="50" />
</datasource>
<datasource group-name="tenantcommon" database-conf-name="mysql" schema-name="">
<inline-jdbc jdbc-uri="jdbc:mysql://127.0.0.1:3307/moquitenantcommon?autoReconnect=true&characterEncoding=UTF-8"
jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2"
pool-maxsize="50" />
</datasource>
</entity-facade>
5.数据库环境略
CREATE DATABASE moquitransactional DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE moquianalytical DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE moquitenantcommon DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
6.用java -Dmoqui.conf=conf/MoquiProductionConf.xml -jar moqui-1.2.0.war -load 加载数据。
7.java -Dfile.encoding=UTF-8 -Dmoqui.conf=conf/MoquiProductionConf.xml -jar moqui-1.2.0.war 启动服务
如果数据库访问权限有问题,尝试以下语句:
GRANT ALL ON moquitenantcommon.* TO moqui@localhost IDENTIFIED BY "moqui";
GRANT ALL ON moquitransactional.* TO moqui@localhost IDENTIFIED BY "moqui";
GRANT ALL ON moquianalytical.* TO moqui@localhost IDENTIFIED BY "moqui";