离线编译maven项目
本文介绍如何在离线状况下编译maven项目。
假设项目分布为:
D->Code ->project ->pom.xml:项目位置
|->Maven ->conf ->settings.xml:maven配置文件的位置
|->repository:存放依赖的位置
命令行编译
先配置maven的配置文件:
<!--settings.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\repository</localRepository>
<offline>true</offline>
</settings>
localRepository
设置本地仓库位置,offline
设置离线模式。
然后在命令行中打开项目的位置,即pom.xml文件所在的位置下,使用命令编译项目:
$ mvn clean package -s "D:/Maven/conf/settings.xml"
-s
设置maven配置文件的位置。