新建了一个maven项目,需要依赖其他项目,当mvn install的时候就出错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新建了一个maven项目,需要依赖其他项目,当mvn install的时候就出错相关的知识,希望对你有一定的参考价值。

出错的提示:
The project com.cisetech.emp:emp-meettingbook-web:0.0.1-SNAPSHOT (F:\some\1.27\trunk\emp-meettingbook-web\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Could not find artifact com.cisetech.emp:emp-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 13 -> [Help 2]

最佳回答:

在此行找到多个注释:

- 生命周期配置中没有涉及的插件执行:org.apache.maven.plugins:maven-compiler-plugin:3.2:testCompile(execution:default-

testCompile,阶段:测试编译)

- CoreException:无法计算构建计划:插件org.apache.maven.plugins:maven-compiler-plugin:3.2或其一个依赖不能

已解决:无法读取org.apache.maven.plugins的工件描述符:maven-compiler-plugin:jar:3.2:ArtifactResolutionException:无法传输

org.apache.maven.plugins:maven-compiler-plugin:pom:3.2从https://repo.maven.apache.org/maven2缓存在本地仓库中,解析不会

重新尝试,直到中央的更新间隔已过或更新被强制。原始错误:无法传输工件org.apache.maven.plugins:maven-

编译器插件:pom:3.2从/到中央(https://repo.maven.apache.org/maven2):连接超时

- 生命周期配置不包含的插件执行:org.apache.maven.plugins:maven-compiler-plugin:3.2:compile(execution:default-compile,

阶段:编译)


参考技术A 你的pom继承了父类pom,但是你的本地库中没有父类pom,无法解析
~如果你认可我的回答,请及时点击【采纳为满意回答】按钮
~~手机提问的朋友在客户端右上角评价点【满意】即可。
~你的采纳是我前进的动力
~~O(∩_∩)O,记得好评和采纳,互相帮助,谢谢。本回答被提问者和网友采纳

接口抽取及依赖版本统一介绍

前面的项目,我们会发现有个接口是一样的,我们需要单独抽取出来,统一维护;

以及两个项目的maven依赖包的版本也是一样的,我们也需要单独抽取出来,统一维护;

 

抽取接口,我们通过新建一个项目,然后其他两个项目依赖这个这个项目即可;

统一依赖包版本,我们可以通过建立parent项目,来统一管理依赖以及版本,子项目继承即可;

 

我们新建dubbo-demo-api项目,然后把DemoProviderService接口类放到该项目里即可;

 

技术分享图片
 1 /**
 2  * 
 3  */
 4 package com.hik.service;
 5 
 6 /**
 7  * @ClassName: DemoProviderService
 8  * @Description: 服务提供者接口
 9  * @author jed
10  * @date 2018年8月25日下午11:52:57
11  *
12  */
13 public interface DemoProviderService {
14 
15     public String sayHello(String name);
16 }
View Code

 

我们再新建一个dubbo-demo-parent项目;

pom.xml里:

技术分享图片
 1 <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">
 2   <modelVersion>4.0.0</modelVersion>
 3   <groupId>com.java1234</groupId>
 4   <artifactId>dubbo-demo-parent</artifactId>
 5   <version>0.0.1-SNAPSHOT</version>
 6   <packaging>pom</packaging>
 7    
 8   <!-- 依赖版本管理 -->
 9   <properties>
10        <dubbo-demo-api.version>0.0.1-SNAPSHOT</dubbo-demo-api.version>
11        <dubbo.version>2.6.0</dubbo.version>
12        <zkclient.version>0.10</zkclient.version>
13        <curator-framework.version>4.0.1</curator-framework.version>
14        <fastjson.version>1.2.46</fastjson.version>
15        <log4j.version>1.2.17</log4j.version>
16        <slf4j-api.version>1.7.25</slf4j-api.version>
17        <commons-lang3.version>3.4</commons-lang3.version>
18        <netty-all.version>4.0.35.Final</netty-all.version>
19   </properties>
20     
21    <!-- 依赖管理-->
22    <dependencyManagement>
23      <dependencies>
24          <dependency>
25                 <groupId>com.java1234</groupId>
26                 <artifactId>dubbo-demo-api</artifactId>
27                 <version>${dubbo-demo-api.version}</version>
28              </dependency>
29             <dependency>
30                 <groupId>com.alibaba</groupId>
31                 <artifactId>dubbo</artifactId>
32                 <version>${dubbo.version}</version>
33             </dependency>
34             <dependency>
35                 <groupId>com.101tec</groupId>
36                 <artifactId>zkclient</artifactId>
37                 <version>${zkclient.version}</version>
38             </dependency>
39             <dependency>
40                 <groupId>org.apache.curator</groupId>
41                 <artifactId>curator-framework</artifactId>
42                 <version>${curator-framework.version}</version>
43             </dependency>
44             <dependency>
45                 <groupId>com.alibaba</groupId>
46                 <artifactId>fastjson</artifactId>
47                 <version>${fastjson.version}</version>
48             </dependency>
49             <dependency>
50                 <groupId>log4j</groupId>
51                 <artifactId>log4j</artifactId>
52                 <version>${log4j.version}</version>
53             </dependency>
54             <dependency>
55                 <groupId>org.slf4j</groupId>
56                 <artifactId>slf4j-api</artifactId>
57                 <version>${slf4j-api.version}</version>
58             </dependency>
59             <dependency>
60                 <groupId>org.apache.commons</groupId>
61                 <artifactId>commons-lang3</artifactId>
62                 <version>${commons-lang3.version}</version>
63             </dependency>
64             <dependency>
65                 <groupId>io.netty</groupId>
66                 <artifactId>netty-all</artifactId>
67                 <version>${netty-all.version}</version>
68             </dependency>
69        </dependencies>
70    </dependencyManagement>
71 </project>
View Code

dubbo-demo-provider项目pom.xml修改:

技术分享图片
 1 <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">
 2   <modelVersion>4.0.0</modelVersion>
 3   <parent>
 4       <groupId>com.java1234</groupId>
 5       <artifactId>dubbo-demo-parent</artifactId>
 6       <version>0.0.1-SNAPSHOT</version>
 7   </parent>
 8   <artifactId>dubbo-demo-provider</artifactId>
 9    
10   <dependencies>
11         <dependency>
12             <groupId>com.java1234</groupId>
13             <artifactId>dubbo-demo-api</artifactId>
14          </dependency>
15         <dependency>
16             <groupId>com.alibaba</groupId>
17             <artifactId>dubbo</artifactId>
18         </dependency>
19         <dependency>
20             <groupId>com.101tec</groupId>
21             <artifactId>zkclient</artifactId>
22         </dependency>
23         <dependency>
24             <groupId>org.apache.curator</groupId>
25             <artifactId>curator-framework</artifactId>
26         </dependency>
27         <dependency>
28             <groupId>com.alibaba</groupId>
29             <artifactId>fastjson</artifactId>
30         </dependency>
31         <dependency>
32             <groupId>log4j</groupId>
33             <artifactId>log4j</artifactId>
34         </dependency>
35         <dependency>
36             <groupId>org.slf4j</groupId>
37             <artifactId>slf4j-api</artifactId>
38         </dependency>
39         <dependency>
40             <groupId>org.apache.commons</groupId>
41             <artifactId>commons-lang3</artifactId>
42         </dependency>
43         <dependency>
44             <groupId>io.netty</groupId>
45             <artifactId>netty-all</artifactId>
46         </dependency>
47     </dependencies>
48 </project>
View Code

类似,dubbo-demo-consumer项目pom.xml修改:

技术分享图片
 1 <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">
 2   <modelVersion>4.0.0</modelVersion>
 3   <parent>
 4       <groupId>com.java1234</groupId>
 5       <artifactId>dubbo-demo-parent</artifactId>
 6       <version>0.0.1-SNAPSHOT</version>
 7   </parent>
 8   <artifactId>dubbo-demo-consumer</artifactId>
 9    
10   <dependencies>
11        <dependency>
12             <groupId>com.java1234</groupId>
13             <artifactId>dubbo-demo-api</artifactId>
14          </dependency>
15         <dependency>
16             <groupId>com.alibaba</groupId>
17             <artifactId>dubbo</artifactId>
18         </dependency>
19         <dependency>
20             <groupId>com.101tec</groupId>
21             <artifactId>zkclient</artifactId>
22         </dependency>
23         <dependency>
24             <groupId>org.apache.curator</groupId>
25             <artifactId>curator-framework</artifactId>
26         </dependency>
27         <dependency>
28             <groupId>com.alibaba</groupId>
29             <artifactId>fastjson</artifactId>
30         </dependency>
31         <dependency>
32             <groupId>log4j</groupId>
33             <artifactId>log4j</artifactId>
34         </dependency>
35         <dependency>
36             <groupId>org.slf4j</groupId>
37             <artifactId>slf4j-api</artifactId>
38         </dependency>
39         <dependency>
40             <groupId>org.apache.commons</groupId>
41             <artifactId>commons-lang3</artifactId>
42         </dependency>
43         <dependency>
44             <groupId>io.netty</groupId>
45             <artifactId>netty-all</artifactId>
46         </dependency>
47   </dependencies>
48 </project>
View Code

修改后测试结果OK的

 

以上是关于新建了一个maven项目,需要依赖其他项目,当mvn install的时候就出错的主要内容,如果未能解决你的问题,请参考以下文章

Maven学习(十八)-----Maven依赖管理

maven pom jar包依赖怎么添加

接口抽取及依赖版本统一介绍

分布式项目中maven互相依赖,如何修改其他项目的jar包?

Idea新建一个SpringBoot项目

##很多时候,我们新建一个Maven工程,第一步都是添加依赖,可是其中的scope代表了什么呢?