Maven mac 配置
转帖 https://blog.youkuaiyun.com/dearKundy/article/details/80291275
完美
1.下载maven http://maven.apache.org/download.cgi#
下载 apache-maven-3.6.2-bin.tar.gz 版本
解压缩
到conf目录
修改setting.xml
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
// 在55行加入
<localRepository>/Users/cxcnew/Documents/maven_local_repo</localRepository>
//保存maven下载资源的文件夹
//在 160行加入
<mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
</mirror>
//阿里云的镜像地址,更改后下载速度快很多
//修改完成后保存
- //建立文件夹仓库 /Users/cxcnew/Documents/maven_local_repo
3.配置环境变量
使用terminal(终端)
vi ~/.bash_profile
插入2行代码
export MAVEN_HOME=/Users/cxcnew/Documents/apache-maven-3.6.2
export PATH=$PATH:$MAVEN_HOME/bin
保存
4.测试 mvn -v
显示 Apache Maven 3.6.2 和jdk版本正确。
5.安装eclpse 插件 maven 插件
eclipse > help >install new software
m2e 输入m2e 选一个 安装
6.配置maven
eclipse > preferences > Maven >installations
add 输入路径 /Users/cxcnew/Documents/apache-maven-3.6.2
finish
钩上 保存
选择 User Setting > 输入刚才修改的setting.xml
/Users/cxcnew/Downloads/apache-maven-3.6.2/conf/settings.xml
Local Repository 输入刚才设置的仓库地址
/Users/cxcnew/Downloads/apache-maven-3.6.2/conf/settings.xml
保存
7.配置完成 Maven 创建项目
左边空白 new 》 Maven 下 Maven Products
选择 maven-archetype-webapp
Group Id 小组名
Artifact Id 项目名
package 包名
finish 完成
8.项目开始 index.jsp 会报错
编辑pom.xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
加入servlet 依赖
保存
ok就可以了
//测试 项目加入到tomcat下 访问地址http://localhost:8080/项目名
看到Hello World! 完成