1.搭建基础目录结构
<packaging>war</packaging>
<properties><!-- 指定jdk版本号 -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<!-- 指定项目编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
2.解压apache-maven-3.6.3,将conf里的settings文件复制到文件夹,然后打开
3.修改localrepository
4.修改mirror
5.修改settings,执行刷新
(webapp会有蓝色圈圈出现)
6.配置web.xml
7.打开project structure
8.setting搜索lombok,下载
一定要保证Enable annotation processing是勾选状态
9.编写插件依赖
10.编辑web.xml,在webapp(项目根目录)下新建文件夹error,新建400.jsp,404.jsp,500.jsp
目录结构:
11.在resources下新建xml,Spring Config,spring-mvc
spring-mav
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 打开注解驱动 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!--指定需要由Spring自主加载的类所在包 定义注解驱动主动扫描的包 -->
<context:component-scan base-package="edu.td.xd"/>
<!-- 创建视图解析器-->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value=""></property><!--定义前缀 -->
<property name="suffix" value=""></property><!--定义前缀 -->
<property name="order" value="1"></property><!--当有多个视图解析器时,排序执行ASC -->
<property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView"></property>
</bean>
</beans>