项目中引入了依赖:java
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.6.0-cdh5.7.1</version> </dependency>
可是经过公司的私服获取后获得此 jar 的 pom 文件为apache
<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 没有去下载,进而致使项目报错。segmentfault
那么问题来了:maven 私服同步的时候回致使同步失败吗 ? 会什么会出现同步后的 pom 不一样的状况?,仍是公司的网络问题?网络
解决方法:一、手动一个一个加上这个jar所须要的dependency依赖,这样太傻了maven
二、网上找一个这个jar的pom依赖文件,根据jar的groupId:artifactId:version去找对应的pom.xml 再去替换一下 oop
找到了以下:(部分)google
<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>
最后再次编译获取后成功解决。code
相似的:https://segmentfault.com/q/1010000005354268component