MessagePack for Java开发指南

github上MessagePack for Java机翻译:来源

MessagePack 是二进制序列化格式。如果您需要快速,紧凑的JSON替代方案,那么MessagePack是您的朋友。例如,可以将一个小整数编码为一个字节,而短字符串则只需要一个字节前缀+原始字节数组即可。MessagePack实现已经有多种语言可用(另请参见http://msgpack.org中的列表),并且可以作为通用数据格式使用.

MessagePack v7 (或者之后的版本) 是较早版本的更快实现v06, 支持所有消息包类型, 包括extension format.


Quick Start

Maven Central

For Maven users:


For sbt users:

libraryDependencies += "org.msgpack" % "msgpack-core" % "(version)"

For gradle users:

repositories {

dependencies {
    compile 'org.msgpack:msgpack-core:(version)'

与Jackson的ObjectMapper集成 (jackson-databind)

有关详细信息,请参见 msgpack-jackson/中使用的基于模板的序列化机制已被弃用

对于MessagePack开发人员 Travis CI

msgpack-java 使用sbt 构建项目. 有关sbt的基本用法,请参见:



Enter the sbt console:

$ ./sbt


> ~compile                                 # Compile source codes
> ~test:compile                            # Compile both source and test codes
> ~test                                    # Run tests upon source code change
> ~testOnly *MessagePackTest               # Run tests in the specified class
> ~testOnly *MessagePackTest -- -n prim    # Run the test tagged as "prim"
> project msgpack-core                     # Focus on a specific project
> package                                  # Create a jar file in the target folder of each project
> findbugs                                 # Produce findbugs report in target/findbugs
> jacoco:cover                             # Report the code coverage of tests to target/jacoco folder
> jcheckStyle                              # Run check style
> ;scalafmt;test:scalafmt;scalafmtSbt      # Reformat Scala codes


> publishLocal            # Install to local .ivy2 repository
> publishM2               # Install to local .m2 Maven repository
> publish                 # Publishing a snapshot version to the Sonatype repository

> release                 # Run the release procedure (set a new version, run tests, upload artifacts, then deploy to Sonatype)

# 如果需要手动执行各个发布步骤,请使用以下命令:
> publishSigned           # Publish GPG signed artifacts to the Sonatype repository
> sonatypeRelease         # Publish to the Maven Central (It will be synched within less than 4 hours)

为了发布到Maven中央,msgpack-java使用sbt-sonatype plugin. Set Sonatype account information (user name and password) in the global sbt settings. To protect your password, never include this file in your project.


credentials += Credentials("Sonatype Nexus Repository Manager",
        "(Sonatype user name)",
        "(Sonatype password)")

Project Structure

msgpack-core                 # Contains packer/unpacker implementation that never uses third-party libraries
msgpack-jackson              # Contains jackson-dataformat-java implementation


Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now