maven 私服同步无法获取依赖的pom.xml的依赖
项目中引入了依赖:
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.6.0-cdh5.7.1</version> </dependency>
但是通过公司的私服获取后得到此 jar 的 pom 文件为
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.6.0-cdh5.7.1</version> <description>POM was created by Sonatype Nexus</description> </project>
从上面看到没有任何依赖项,所以 maven 没有去下载,进而导致项目报错。
那么问题来了:maven 私服同步的时候回导致同步失败吗 ? 会什么会出现同步后的 pom 不同的情况?,还是公司的网络问题?
解决方法:1、手动一个一个加上这个jar所需要的dependency依赖,这样太傻了
2、网上找一个这个jar的pom依赖文件,根据jar的groupId:artifactId:version去找对应的pom.xml 再去替换一下
找到了如下:(部分)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-project-dist</artifactId> <version>2.6.0-cdh5.7.1</version> <relativePath>../../hadoop-project-dist</relativePath> </parent> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.6.0-cdh5.7.1</version> <description>Apache Hadoop Common</description> <name>Apache Hadoop Common</name> <packaging>jar</packaging> <properties> <hadoop.component>common</hadoop.component> <is.hadoop.component>true</is.hadoop.component> <wsce.config.dir>../etc/hadoop</wsce.config.dir> <wsce.config.file>wsce-site.xml</wsce.config.file> </properties> <dependencies> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-annotations</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>xmlenc</groupId> <artifactId>xmlenc</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <scope>compile</scope> </dependency>
最后再次编译获取后成功解决。
类似的:https://segmentfault.com/q/1010000005354268
业精于勤荒于嬉 行成于思毁于随