項目中引入了依賴: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