一、创建webapp项目
1、选择maven项目
2、选择jdk版本
3、勾选骨架:create from archetype
4、选择webapp
next
next
这里我使用重新配置过的这两个,参考上一篇自定义maven仓库以及使用阿里镜像
不配置而使用默认的,会导致构建项目非常的慢,因为默认是外网下
二、配置pom.xml文件
maven的编译版本选择jdk1.8,另外在下面锁定spring的版本为5.0.2.RELEASE,因为使用spring的一个依赖,其他spring框架下的依赖都得是同一个版本的,所以这里直接写一个引用,要改的时候直接在这个引用上面改就可以了
添加依赖:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
三、配置服务器
如上图,发现下面有个warning,说是没有artifacts,接下来来添加
选择项目名称对应的这个即可
然后该页会出现这个框框,选择项目名称的那个即可
大功告成了,run一把试试,run会默认run他项目默认带的那个index,jsp,里面写了helloword