1.保证MySQL 版本高于 5.5.3
2.确保mysql-connector-java-版本高于5.1.1-bin.jar
3.正确配置数据库 utf8mb4
4.更改ofbiz对于mysql字段长度的定义
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set = utf8mb4
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
collation-server = utf8mb4_general_ci
init-connect=?.ET NAMES utf8mb4?
character-set-server = utf8mb4
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_large_prefix = 1
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
default-character-set = utf8mb4
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
注意 innodb_large_prefix 、innodb_file_format
检查是否正确
show variables like '%character%';
show variables like 'innodb_large_prefix';
show variables like 'innodb_file_format';
创建UTF8MB4数据库、及测试数据表是否正常插入表情
create database databaseName CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
use databaseName;
create table test (value varchar(255));
insert into asdf values ('表情');
#此处无法粘贴进来。自己找
接下来正常的OFBiz导表流程
如果出现
Specified key was too long; max key length is 767 bytes 或 java.sql.SQLException -> Index Column Size too large。
Maximum Column Size is 767 Byte
--
That error means you are trying to add unique index on a varchar(255) utf8mb4 column. In utf8mb4 column, each character needs 4 bytes. So 255 characters means 1020 bytes. The max key length is 767 bytes.
增加 fieldtypemysql_utf8mb4.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd">
<!-- ===================== field-type-def ==================== -->
<!-- General Types -->
<field-type-def type="blob" sql-type="LONGBLOB" java-type="java.sql.Blob"/>
<field-type-def type="byte-array" sql-type="LONGBLOB" java-type="byte[]"/>
<field-type-def type="object" sql-type="LONGBLOB" java-type="Object"/>
<field-type-def type="date-time" sql-type="DATETIME(3)" java-type="java.sql.Timestamp"/>
<field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"/>
<field-type-def type="time" sql-type="TIME(3)" java-type="java.sql.Time"/>
<field-type-def type="currency-amount" sql-type="DECIMAL(18,2)" java-type="java.math.BigDecimal"/>
<field-type-def type="currency-precise" sql-type="DECIMAL(18,3)" java-type="java.math.BigDecimal"/>
<field-type-def type="fixed-point" sql-type="DECIMAL(18,6)" java-type="java.math.BigDecimal"/>
<field-type-def type="floating-point" sql-type="DOUBLE" java-type="Double"/>
<field-type-def type="numeric" sql-type="DECIMAL(20,0)" java-type="Long"/>
<field-type-def type="id" sql-type="VARCHAR(20)" java-type="String"/>
<field-type-def type="id-long" sql-type="VARCHAR(60)" java-type="String"/>
<field-type-def type="id-vlong" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="indicator" sql-type="CHAR(1)" java-type="String"/>
<field-type-def type="very-short" sql-type="VARCHAR(10)" java-type="String"/>
<field-type-def type="short-varchar" sql-type="VARCHAR(60)" java-type="String"/>
<field-type-def type="long-varchar" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="very-long" sql-type="LONGTEXT" java-type="String"/>
<field-type-def type="comment" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="description" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="name" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="value" sql-type="VARCHAR(191)" java-type="String"/>
<!-- Specialized Types -->
<field-type-def type="credit-card-number" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="credit-card-date" sql-type="VARCHAR(7)" java-type="String"/>
<field-type-def type="email" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="url" sql-type="LONGTEXT" java-type="String"/>
<field-type-def type="id-ne" sql-type="VARCHAR(20)" java-type="String"/>
<field-type-def type="id-long-ne" sql-type="VARCHAR(60)" java-type="String"/>
<field-type-def type="id-vlong-ne" sql-type="VARCHAR(191)" java-type="String"/>
<field-type-def type="tel-number" sql-type="VARCHAR(60)" java-type="String"/>
</fieldtypemodel>
修改 entityengine.xml
<field-type name="mysql" loader="fieldfile" location="fieldtypemysql_mb4.xml"/>
使配置适用 Utf8mb4
分享到:
相关推荐
CREATE DATABASE ofbiz CHARACTER SET utf8 COLLATE utf8_general_ci; ``` `CHARACTER SET utf8`定义了数据库的字符集,而`COLLATE utf8_general_ci`定义了排序规则,ci表示大小写不敏感。 2. **配置数据库连接*...
2. 工作空间字符集设置:我们需要将 Eclipse 的工作空间字符集设置为“UTF-8”,以便与 Ofbiz 的编码格式保持一致。我们可以在 Eclipse 的“Window”菜单中选择“Preferences”,然后选择“General” > “Workspace...
【ofbiz综合使用手册】是针对初学者的指导材料,主要介绍了如何配置和使用ofbiz这一企业级开源应用框架。ofbiz遵循了Model-View-Controller(MVC)设计模式,这种模式对于大型商业逻辑项目的开发尤其有益,因为它...
4. OFBiz工作环境设置:需要配置OFBiz的工作环境,并设置在Eclipse这样的集成开发环境(IDE)中的项目。 5. 使用Derby数据库:Derby是一个小型的开源数据库,是OFBiz的默认数据库。涉及如何安装、备份和恢复数据...
通常,MySQL支持多种字符集,但为了更好地兼容中文,推荐使用`utf8`或更新的`utf8mb4`编码格式。 ##### 步骤: - 打开MySQL安装目录下的`my.ini`文件。例如,在Windows环境下,路径可能为`C:\Program Files\MySQL\...
- `character-set="utf8"`和`collate="utf8_general_ci"`:设置字符集和排序规则。 ### 配置其他参数 - `check-on-start`、`add-missing-on-start`和`check-pks-on-start`:控制Ofbiz在启动时对数据库的检查和处理...
Ofbiz,全称为The Open For Business Project,是一个开源的企业应用框架,主要由Apache软件基金会维护。这个项目旨在提供一套全面的、可扩展的企业级应用程序解决方案,涵盖了电子商务、供应链管理、客户关系管理等...
4. **API与服务**:OfBiz提供了丰富的API接口和服务,允许开发者进行定制化开发,扩展系统功能。在Demo中,开发者可以查看这些接口的使用示例,了解如何集成外部系统。 5. **文档资料**:除了代码和演示数据,...
Ofbiz使用Spring框架作为其依赖注入容器,使得组件和服务之间能够灵活地协作。 自学Ofbiz时,首先需要熟悉其开发环境的搭建。这通常涉及下载源码,配置Java环境,以及安装和设置Ant或Maven构建工具。然后,你需要...
标题中的"ofbiz10.04表结构"指的是OFBiz 10.04版本的数据模型设计,这是企业级开源应用框架OFBiz的一个重要组成部分。OFBiz全称为Open For Business Project,它是一个用于构建企业应用程序的全面业务解决方案,涵盖...
4. Git:版本控制系统,用于跟踪和管理OFBiz源代码的变更。 Git的安装步骤如下: 1. 访问官方网站或通过搜索引擎找到msysGit的下载链接(例如:http://code.google.com/p/msysgit/downloads/list)。 2. 下载并...
完成这些配置后,保存文件,OFBiz现在应该能与PostgreSQL数据库正确交互。启动OFBiz服务,通过访问OFBiz的Web界面来验证安装是否成功。如果一切正常,你现在已经在Windows 7环境下成功地搭建了OFBiz与PostgreSQL的...
4. **API 使用指南** 在使用OFBiz API时,开发者需要注意以下几点: - **服务调用**:了解如何通过HTTP请求或者Java代码调用OFBiz服务,通常需要正确设置服务端点和参数。 - **权限管理**:OFBiz API通常需要身份...
- **下载 JDK 5.0**:虽然这里提到的是 JDK 5.0,但建议使用更新的版本,如 JDK 8 或更高版本。 - **安装 JDK 5.0**:提供详细的安装步骤。 - **下载 OFBiz Ready to Launch**:提供 OFBiz 预配置环境的下载链接。...
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE entitymodel PUBLIC "-//OFBiz//DTD Entity Model//EN" "http://www.ofbiz.org/dtds/entitymodel.dtd"> <title>Entity of an Open For Business Project ...