1. 下载maven
- 进入下载页面:http://maven.apache.org/download.cgi
-
选择下载内容:
- 配置maven信息
3.1 进入控制台,编辑~/.bash_profile
设置maven_home,并加入到path中,如下所示
MAVEN_HOME=/Users/chenzhongqiang/Downloads/apache-maven-3.6.2
PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH:.
export MAVEN_HOME
export JAVA_HOME
export PATH
- 3.2 保存后,执行source ~/.bash_profile
- 3.3 执行 mvn -Version,如果显示maven版本信息,则说明安装成功
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: /Users/chenzhongqiang/Downloads/apache-maven-3.6.2
-
3.4 进入/.m2,设置settings.xml中的远程maven仓库地址(注意:如果/.m2中没有settings.xml文件,从上面下载的maven文件中的conf/settings.xml复制一份)
3.5 maven 配置文件配置settings.xml中设置mirrors节点增加为阿里云的镜像地址
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror> </pre>
-
3.6 eclipse设置maven路径
进入perferences->maven->installations,如下图,设置maven的地址
设置
2 maven 打包
如果在eclipse中直接执行maven build,goals填写clean package
2.1 maven打包,把依赖也打到一个jar包内
maven build 中goal设置为clean package
pom文件添加build信息
<build>
<finalName>excel_extractor</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>excel_extractor</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>