eclipse中使用maven
我的eclipse EE的版本
maven首先回去查找你的本地仓库是否有你需要的jar没才去网上仓库查找(这里一般不用它官网的仓库【太卡了】,推荐使用阿里仓库,【最近华为的仓库好像已经比较完善了也可试试】)
点开window下preference搜索maven选择install
里面已经有个内置的3.3.9的maven(当然我们不用它)
点击add添加maven
点击finish就可以(我这里是因为已经安装了这个版本)
然后配置要使用的配置文件setting.xml
点开window下preference搜索maven选择use settings
在use settings这个配置你的maven中的setting.xml的地址
下面的local repository是你的本地仓库地址(放置你下载的jar包)
配置阿里仓库:
点击use settings后面的open file,打开你配置的配置文件,修改下面的配置
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
到此eclipse的maven的配置就基本ok了
下面是新建项目过程:
//---------------------------------------------------------------------
新建maven项目
file->new->maven project->勾选create a simple project->next
group id是组名(公司名一般填域名就行)
artifact id 是项目名 version是版本号 packaging是打包方式
最后finish
新建的项目缺了web.xml你自己copy一个放到webapp下的WEB-INF下就ok了
java中是放你的java代码,resources是配置文件,webapp就是以前的webroot了,test里面写测试方法
pom.xml是写你的需求jar包
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.1024gd</groupId>
<artifactId>sshp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
build标签里是jre版本的(如果是像以前的web项目区修改configure build path去修改jre的话是没用的)
到此eclipse的maven就基本ok了