运行环境
- JDK 1.8
- eclipse Oxygen.3a Release
- maven 4.00
使用本地jar包
1.打开cmd执行以下命令
mvn install:install-file -Dfile=jar-path -DgroupId=groupId -DartifactId=dartifactId -Dversion=version -Dpackaging=jar
需要配置命令 | 说明 |
---|---|
-Dfile | 将要引入jar包绝对路径 |
-DgroupId | 对应JAVA的包的结构 |
-DartifactId | 对应项目的名称 |
-Dversion | jar版本号 |
2.配置pom.xml
根据以上表格中配置的命令,在pom.xml中添加相应配置
<project>
...
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
...
</project>
使用远程仓库
添加 central.maven 远程仓库的详细信息在“pom.xml”文件。
<project>
...
<repositories>
<repository>
<id>central maven</id>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
...
</project>
如果识别不成功,在项目根目录执行命令(仅供参考)
1. mvn eclipse:clean
2. mvn eclipse:eclipse
3. eclipse中删除项目(不删除本地)
4. eclipse => import -> Existing Projects
5. 完成