用idea创建springMVC maven-5.2

http://www.jianshu.com/p/2101d176555b

1.创建module

2.选择maven

写好Maven的俩参数,GroupId和ArtefactId,版本

//upload-images.jianshu.io/upload_images/1112615-b92b35acf0ceea58.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240

3.在Module文件上单机右健

菜鸟请勾上Create empty spring-config.xml
如果你有本地Maven库的话,选择Set up library later
没有可以选择Download

项目结构变成了下面的样子

 

配置扫包目录:
最好新建一个SpringConfig的XML配置文件,用的源生applicationContext.xml

 

web.xml 文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

 

posted on 2017-05-02 12:56  积累学习  阅读(180)  评论(0编辑  收藏  举报

导航