As already suggested by nandsito, and to expand on its answer, try this (untested, let me know and I'll update):<profiles> <profile> <id>osx</id> <dependency> <groupId>org.bytedeco.javacpp-presets</groupId> <artifactId>tensorflow</artifactId> <version>0.9.0-1.2</version> <classifier>macosx-x86_64</classifier> </dependency> </profile> <profile> <id>linux</id> <dependency> <groupId>org.bytedeco.javacpp-presets</groupId> <artifactId>tensorflow</artifactId> <version>0.9.0-1.2</version> <classifier>linux-x86_64</classifier> </dependency> </profile></profiles>并删除所有其他相关的<dependency>节点,这些节点都位于您的POM中(这样,如果没有<profiles>部分,就不会依赖tensorflow.)And remove all the related <dependency> nodes elsewere in your POM (so that without the <profiles> part there would be no dependency for tensorflow).此更改后,您每次都必须指定一个配置文件(因为POM中将没有tensorflow依赖性):在MacOs mvn clean package -Pmacos上准备软件包时以及在Centos mvn clean package -Plinux上准备软件包时After this change you'll necessarily have to specify a profile each time (as there will be no tensorflow dependency in the POM): when preparing the package on MacOs mvn clean package -Pmacos and when preparing the package on Centos mvn clean package -Plinux Eclipse允许您在Project properties> Maven下设置活动配置文件列表(您可以通过右键单击Project explorer中的项目文件夹来进入此窗口.Eclipse allows you to set a list of active profiles under Project properties > Maven (you can get to this window by right-clicking on the project folder in the Project explorer. 这篇关于如何使用Maven为特定操作系统构建jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-20 22:33