解决maven无法获取${os.detected.classifier}的问题

解决maven无法获取${os.detected.classifier}的问题

mvn package报错信息

Could not transfer artifact io.netty:netty-tcnative-boringssl-static:jar:${os.detected.classifier}:2.0.7.Final from/to nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public): TransferFailedException

异常图片

解决方式

异常提示很明确,maven无法获取到属性os.detected.classifier,那么只需要指定该属性,并且在mvn命令执行时能获取到就解决了。

1、windows系统

命令行运行增加: -Dos.detected.classifier=windows-x86_64

mvn package -Dos.detected.classifier=windows-x86_64

IDEA中使用maven插件需要配置虚拟机引数(VM Options)
VM Options:

-Dos.detected.classifier=windows-x86_64

File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner
配置图片
这样虽然可以正常执行mvn命令,但是你会发现maven插件的依赖检查依然报红(这是由于之前指定的是运行时的参数,在运行前是无法获取到的)
maven依赖图片
可以通过修改maven的settings.xml文件解决
添加如下内容:

<profiles>
  <profile>
    <id>os-properties</id>
    <properties>
         <!--Linux-->
          <!--<os.detected.name>linux</os.detected.name>
		  <os.detected.arch>x86_64</os.detected.arch>
		  <os.detected.classifier>linux-x86_64</os.detected.classifier>
		  -->
		  <!--Windows-->
		  <os.detected.classifier>windows-x86_64</os.detected.classifier>
    </properties>
  </profile>
</profiles>

<activeProfiles>
  <activeProfile>os-properties</activeProfile>
</activeProfiles>

如果还是不能解决,可以直接添加环境变量:
MAVEN_OPTS
-Dos.detected.classifier=windows-x86_64
环境变量

2、Linux系统

mvn命令增加一些引数

-Dos.detected.name=linux -Dos.detected.arch=x86_64 -Dos.detected.classifier=linux-x86_64

也可以

vi /etc/profile
#在末尾添加:
export MAVEN_OPTS=-Dos.detected.classifier=linux-x86_64

未验证的问题

x86架构的服务器正常执行,arm架构的服务器节后验证。
适配参数

参考

  • 7
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值