zhltom 发表于 2018-6-12 12:34:52

windows下eclipse配置maven

windows下eclipse配置maven
  目录:
一、maven安装
二、eclipse配置maven
三、使用maven导入SpringMVC基础依赖包

一、maven安装
  1、下载
到http://maven.apache.org/download.cgi 上面下载对应的maven包

2、解压
将刚刚下载的包apache-maven-3.5.2-bin.zip解压
3、设置环境变量
1) 添加MAVEN_HOME,解压后的路径
2) 在path末尾加入;%MAVEN_HOME%\bin
4、测试是否成功
打开终端cmd,输入mvn --version

5、创建一个新的文件夹I:\apache-maven-3.5.2\maven_dependcies
6、修改配置文件setting.xml
1) 将默认空间修改为上一步创建的文件夹,修改setting.xml的54行下面,添加

<localRepository>I:\apache-maven-3.5.2\maven_dependcies</localRepository>

2) 修改镜像位置,改为阿里云的镜像,修改setting.xml的147行:

<mirror>      
<id>alimaven</id>   
<name>aliyun maven</name>         
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>         
<mirrorOf>central</mirrorOf>      
</mirror>


二、eclipse配置maven
  1、打开eclipse,选择一个新的workspace:E:\eclipse\file3

2、新建一个名为test的maven项目

1) 生成web.xml文件

2) 添加tomcat的jar包


3、将maven加入eclipse
1) Windows——>Perferances——>Maven——>Installions——>Add——>Directory——>选择maven



2) Windows——>Perferances——>Maven——>User Setting——>Browse(第二个Browse)——>选择settiing.xml文件——>Update Setting——>Apply——>OK



4、测试maven是否成功
1) 打开maven配置文件pom.xml
2) 在<project></project>中加入:

    <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
  然后Ctrl+s保存
3) 然后观察maven项目中的Librarieszhong的Maven Dependencies中会多出:

到此,maven配置完成!!!

三、使用maven导入SpringMVC基础依赖包
  1、通过浏览器访问阿里云maven库http://maven.aliyun.com/nexus/#welcome

2、输入springmvc搜索

3、在搜索结果中选择合适的版本,并且复制右边对应的xml代码

<dependency>
<groupId>org.statefulj.framework</groupId>
<artifactId>statefulj-framework-binders-springmvc</artifactId>
<version>2.1</version>
<classifier>javadoc</classifier>
</dependency>
</dependencies>

4、将复制的xml代码放入eclipse项目的maven配置文件pom.xml中,并且Ctrl+s保存

5、在项目的maven库中会多出许多水平mvc依赖包
页: [1]
查看完整版本: windows下eclipse配置maven