idea创建基于maven的ssm项目【2】配置springmvc.xml

时间:2019-03-20
本文章向大家介绍idea创建基于maven的ssm项目【2】配置springmvc.xml,主要包括idea创建基于maven的ssm项目【2】配置springmvc.xml使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

本节操作完成了对spring子容器的配置。

1、创建源代码和配置文件所在目录

  • 创建java文件夹,设置为Sources Root,具体操作如下图所示:

 

2、创建各层package

  • 创建controller
  • 创建service
  • 创建mapper
  • 创建entity

具体操作如下图所示:

 

3、在resources中创建springmvc.xml

具体操作如下图所示:

 

4、修改springmvc.xml

<?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"
       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">
    <!--扫描controller层-->
    <context:component-scan base-package="net.wanho.controller"></context:component-scan>
    <!--以标签的方式创建处理器映射器以及处理器适配器-->
    <mvc:annotation-driven></mvc:annotation-driven>
</beans>

至此,我们完成了对spring子容器的配置。