前言
在引用rocketMQ的java客户端类库时候,
在pom文件上面添加:
<dependencies>
<!--引入消息队列客户端 begin -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-common</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.2.0</version>
</dependency>
<!--引入消息队列客户端 end -->
</dependencies>
然后你会看到:
maven的deploy都不起作用了,何解?
下面引用资料:
netty源码构建找不到netty-tcnative包 — Maven 元素
在构建netty的时候遇到一个问题,总是报netty-tcnative包找不到,这就奇了怪了,都是官方的源码,怎么会报错?
结果在maven本地库里面发现netty-tcnative包后面总是被加上了系统变量的名字,变成了netty-tcnative-1.1.32.Fork1_x86_64的字样。
问题就出在下面这个maven配置中:
1
2
3
4
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-tcnative</artifactId>
<version>1.1.32.Fork1</version>
<classifier>${os.detected.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<classifier>${os.detected.classifier}</classifier>
它相当于是在maven包名字后面再加了一个后缀,用作版本或者特殊化区分的配置。
${os.detected.classifier}就相当于上面的_x86_64。
再进一步,原来netty-tcnative这个包也不属于netty项目的一部分,而是作为一个独立项目发布的,我猜测应该是作者在开发环境中为了做跨平台的时候加的东西吧,因为里面有jni,但是正式发布的时候是没有后面那些东西的。
注意了,rocketMQ是需要调用netty的相关jar的,netty all.jar又要用到netty-tcnative,所以就报这个错了,于是:
<!--引入消息队列客户端 begin -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-common</artifactId>
<version>4.2.0</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>1.1.33.FORK22</version>
</dependency>
<!--引入消息队列客户端 end -->
先在rocketMQ的common下面对netty-tcnative排除一下,不编译这个jar,然后自己额外添加netty-tcnative的一个依赖。