赞
踩
选择手动输入groupId和artifactId
,这样它就会提示version ]dependencyManagement
> 来管理依赖,如果有使用该标签,则会导致的一种情况是:子模块中导入某个依赖(该依赖不需要再父工程导入,只用在某个子模块中),子模块导入成功,没有报错,但是通过maven工具的窗口观察,发现依赖并没有出现在Dependecies
;
------------ 之所以介绍 groupId、artifactId,是因为在 pom.xml 有时候引入依赖发生错误,提示找不到类的时候,需要考虑是不是 groupId、artifactId 引入错误 ------------
■ 举例,artifactId:同样是 commons.codec的,在maven仓库中,就找到了三个不同的groupId:
<!-- 在项目引入报错,提示找不到 -->
<!-- https://mvnrepository.com/artifact/commons.codec/commons-codec -->
<dependency>
<groupId>commons.codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<!-- 在项目引入成功,可以正常使用该jar包的方法 -->
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<!-- 在项目引入成功,可以正常使用该jar包的方法 -->
<!-- https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.codec -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
</dependency>
实在不行,手动导入!!!
从maven仓库下载对应版本的jar包
到自己的电脑:命令行向maven项目导入jar包
,然后刷新一下maven项目:mvn install:install-file -Dfile="jar包的位置" -DgroupId=jar包的groupId坐标 -DartifactId=jar包的artifactId坐标 -Dversion=jar包的version坐标 -Dpackaging=jar
环境变量
:□ M2_HOME maven目录下的bin目录
□ MAVEN_HOME maven的目录
□ 在系统的path中配置 %MAVEN_HOME%\bin
阿里云镜像
配置文件位置:maven根目录/conf/settings.xml 找到镜像元素mirrors
镜像:mirrors:
阿里云
镜像加速下载 <!-- 添加之前,先把原来的镜像全注释掉 -->
<!-- 配置方式1 -->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<!-- 配置方式2 -->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
本地仓库位置
<localRepository>E:\environment\mavenEvironment\apache-maven-3.8.2\maven-repo</localRepository>
如果本文对你有帮助的话记得给一乐点个赞哦,感谢!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。