程序员使用Mac的M芯片后遇到的问题

这里写自定义目录标题

  • 前言
    • 环境
  • 问题
    • 问题1:编译时protobuf编译不通过
      • 问题
      • 解决

学海无涯,旅“途”漫漫,“途”中小记,如有错误,敬请指出,在此拜谢!

前言

期待已久的M2芯片的macbookpro终于到货了,无比喜欢。不过从原先的芯片换到M芯片,确实有很多不一样的地方啊。特写本文章记录。

环境

参数 描述
JDK jdk-11.0.18_macos-aarch64_bin
MAVEN apache-maven-3.8.7-bin

问题

问题1:编译时protobuf编译不通过

问题

编译的时候出现以下内容

[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project message: Unable to resolve artifact: Missing:
[ERROR] ----------
[ERROR] 1) com.google.protobuf:protoc:exe:osx-aarch_64:3.17.2
[ERROR] 
[ERROR]   Try downloading the file manually from the project website.
[ERROR] 
[ERROR]   Then, install it using the command: 
[ERROR]       mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=3.17.2 -Dclassifier=osx-aarch_64 -Dpackaging=exe -Dfile=/path/to/file
[ERROR] 
[ERROR]   Alternatively, if you host your own repository you can deploy the file there: 
[ERROR]       mvn deploy:deploy-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=3.17.2 -Dclassifier=osx-aarch_64 -Dpackaging=exe -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] 
[ERROR]   Path to dependency: 
[ERROR]   	1) x.x.x.x:3.3.4.1
[ERROR]   	2) com.google.protobuf:protoc:exe:osx-aarch_64:3.17.2
[ERROR] 
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR] 
[ERROR] for artifact: 
[ERROR]   x.x.x.x:3.3.4.1
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   aliyunmaven (https://maven.aliyun.com/repository/central, releases=true, snapshots=true),
[ERROR]   spring-snapshots (https://repo.spring.io/snapshot, releases=true, snapshots=true),
[ERROR]   spring-milestones (https://repo.spring.io/milestone, releases=true, snapshots=false),
[ERROR]   typesafe (https://repo.typesafe.com/typesafe/releases/, releases=true, snapshots=true),
[ERROR]   sonatype (https://oss.sonatype.org/content/groups/public, releases=true, snapshots=true)
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn  -rf :message

经过排查发现,是因为使用的protobuf这个jar包,到现在还没有M芯片版本的。需要单独配置settings文件。

解决

maven的setting.xml增加一下配置。(参考于:https://github.com/grpc/grpc-java/issues/7690)

<settings>
  ...
  <activeProfiles>
    <activeProfile>
      apple-silicon
    activeProfile>
    ...
  activeProfiles>
  <profiles>
    <profile>
      <id>apple-siliconid>
      <properties>
        <os.detected.classifier>osx-x86_64os.detected.classifier>
      properties>
    profile>
    ...
  profiles>
  ...
settings>

你可能感兴趣的:(JAVA相关,java)