Broadleaf电商系统开发(四) - 切换到mysql
2016-01-31 21:19
811 查看
Broadleaf 默认使用的数据库是hsqldb,所有数据都存储在内存中,每次重启服务器,数据销毁再重键。因此在生产环境中,肯定要切换到其他数据库如mysql,这里介绍的就是使用Mysql数据库。
官方的参考文档如下:
http://www.broadleafcommerce.com/docs/core/current/tutorials/getting-started-tutorials/switch-to-mysql-tutorial http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/key-aspects-and-configuration/database-configuration
http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/key-aspects-and-configuration/persistence-configuration
1、首先安装mysql、创建数据库、用户
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mall` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE USER
malluser@localhost IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON mall.* TO malluser@localhost;
FLUSH PRIVILEGES;/
2、然后用mysql替换掉主目录pom文件中tomcat插件对hsqldb的依赖:注意位置不变
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
3、替换掉core/src/main/resources/runtime-properties/common-shared.properties中的方言配置
blPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blSecurePU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blCMSStorage.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect/
4、修改主目录build.properties中的数据库连接配置
database.user=malluser
database.password=123456
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=UTF-8
5、修改site/build.xml中的target
<target name="tomcat" depends="start-db"> 改为 <target name="tomcat">
<target name="tomcat-jrebel" depends="start-db"> 改为 <target name="tomcat-jrebel">
6、注意
为了避免每次启动都重新创建数据库,修改DemoSite/site/src/main/resources/runtime-properties/development.properties
先改为
blPU.hibernate.hbm2ddl.auto=create
blCMSStorage.hibernate.hbm2ddl.auto=update
blSecurePU.hibernate.hbm2ddl.auto=update
执行ant tomcat后,停止tomcat,再改为(上面创建数据库,下面不再重复创建)
blPU.hibernate.hbm2ddl.auto=update
blCMSStorage.hibernate.hbm2ddl.auto=update
blSecurePU.hibernate.hbm2ddl.auto=update
官方的参考文档如下:
http://www.broadleafcommerce.com/docs/core/current/tutorials/getting-started-tutorials/switch-to-mysql-tutorial http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/key-aspects-and-configuration/database-configuration
http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/key-aspects-and-configuration/persistence-configuration
1、首先安装mysql、创建数据库、用户
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mall` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE USER
malluser@localhost IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON mall.* TO malluser@localhost;
FLUSH PRIVILEGES;/
2、然后用mysql替换掉主目录pom文件中tomcat插件对hsqldb的依赖:注意位置不变
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
3、替换掉core/src/main/resources/runtime-properties/common-shared.properties中的方言配置
blPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blSecurePU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blCMSStorage.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect/
4、修改主目录build.properties中的数据库连接配置
database.user=malluser
database.password=123456
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=UTF-8
5、修改site/build.xml中的target
<target name="tomcat" depends="start-db"> 改为 <target name="tomcat">
<target name="tomcat-jrebel" depends="start-db"> 改为 <target name="tomcat-jrebel">
6、注意
为了避免每次启动都重新创建数据库,修改DemoSite/site/src/main/resources/runtime-properties/development.properties
先改为
blPU.hibernate.hbm2ddl.auto=create
blCMSStorage.hibernate.hbm2ddl.auto=update
blSecurePU.hibernate.hbm2ddl.auto=update
执行ant tomcat后,停止tomcat,再改为(上面创建数据库,下面不再重复创建)
blPU.hibernate.hbm2ddl.auto=update
blCMSStorage.hibernate.hbm2ddl.auto=update
blSecurePU.hibernate.hbm2ddl.auto=update
相关文章推荐
- 盘点2020中国电商平台TOP10
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜