使用 lettuce 4.4 和 play framework 2.5.5
Using lettuce 4.4 with play framework 2.5.5
我正在尝试将 lettuce 4.4 版用作 play framework 2.5.5 项目中的 Redis 客户端库。 play 2.5.5 和 lettuce 4.4 使用的 netty 版本似乎存在一些兼容性问题。
当 Redis 客户端试图连接到本地安装的 Redis 服务器时,我看到 java.nio.channels.UnresolvedAddressException
。我已确保 Redis 服务器 运行 正常。此外,我能够使用基于独立 Maven 的 java 项目的 lettuce 4.4 连接到 redis。
为了解决这个问题,我在独立的maven项目中重现了这个问题,通过明确指定netty依赖如下:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.20.Final</version>
</dependency>
而且我能够通过使用 shaded-jar 解决 Maven 项目中的问题,其中依赖项被重新定位到 com.lambdaworks
包以避免版本冲突,如 https://github.com/lettuce-io/lettuce-core#binariesdownload 中所述。要使用阴影 jar,将 'classifier' 属性 添加到值为 'shaded' 的 lettuce 依赖项定义中,并且还指定了排除列表。如何使用 build.sbt?
实现相同的效果
根据 http://www.scala-sbt.org/0.13/docs/Library-Management.html#Exclude+Transitive+Dependencies,我可以在 build.sbt 中指定排除项,但不确定如何设置分类器 属性。仅凭排除列表,它似乎不起作用。
最后,我能够通过在 build.sbt 中指定 shaded
分类器和 exclusions
来解决问题,如下所示:
"biz.paluch.redis" % "lettuce" % "4.4.0.Final" classifier "shaded" excludeAll(
ExclusionRule(organization = "io.reactivex", artifact="rxjava"),
ExclusionRule(organization = "org.latencyutils", artifact="LatencyUtils"),
ExclusionRule(organization = "io.netty", artifact="netty-common"),
ExclusionRule(organization = "io.netty", artifact="netty-transport"),
ExclusionRule(organization = "io.netty", artifact="netty-handler"),
ExclusionRule(organization = "io.netty", artifact="netty-codec"),
ExclusionRule(organization = "com.google.guava", artifact="guava"),
ExclusionRule(organization = "io.netty", artifact="netty-transport-native-epoll"),
ExclusionRule(organization = "io.apache.commons", artifact="commons-pool2"))
)
我正在尝试将 lettuce 4.4 版用作 play framework 2.5.5 项目中的 Redis 客户端库。 play 2.5.5 和 lettuce 4.4 使用的 netty 版本似乎存在一些兼容性问题。
当 Redis 客户端试图连接到本地安装的 Redis 服务器时,我看到 java.nio.channels.UnresolvedAddressException
。我已确保 Redis 服务器 运行 正常。此外,我能够使用基于独立 Maven 的 java 项目的 lettuce 4.4 连接到 redis。
为了解决这个问题,我在独立的maven项目中重现了这个问题,通过明确指定netty依赖如下:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.20.Final</version>
</dependency>
而且我能够通过使用 shaded-jar 解决 Maven 项目中的问题,其中依赖项被重新定位到 com.lambdaworks
包以避免版本冲突,如 https://github.com/lettuce-io/lettuce-core#binariesdownload 中所述。要使用阴影 jar,将 'classifier' 属性 添加到值为 'shaded' 的 lettuce 依赖项定义中,并且还指定了排除列表。如何使用 build.sbt?
根据 http://www.scala-sbt.org/0.13/docs/Library-Management.html#Exclude+Transitive+Dependencies,我可以在 build.sbt 中指定排除项,但不确定如何设置分类器 属性。仅凭排除列表,它似乎不起作用。
最后,我能够通过在 build.sbt 中指定 shaded
分类器和 exclusions
来解决问题,如下所示:
"biz.paluch.redis" % "lettuce" % "4.4.0.Final" classifier "shaded" excludeAll(
ExclusionRule(organization = "io.reactivex", artifact="rxjava"),
ExclusionRule(organization = "org.latencyutils", artifact="LatencyUtils"),
ExclusionRule(organization = "io.netty", artifact="netty-common"),
ExclusionRule(organization = "io.netty", artifact="netty-transport"),
ExclusionRule(organization = "io.netty", artifact="netty-handler"),
ExclusionRule(organization = "io.netty", artifact="netty-codec"),
ExclusionRule(organization = "com.google.guava", artifact="guava"),
ExclusionRule(organization = "io.netty", artifact="netty-transport-native-epoll"),
ExclusionRule(organization = "io.apache.commons", artifact="commons-pool2"))
)