美文网首页
SSM框架搭建

SSM框架搭建

作者: 一腔诗意换酒钱 | 来源:发表于2020-02-25 13:54 被阅读0次

SSM框架搭建

1.新建maven工程

File->New->Project->Maven

2.配置pom.xml

2.1

<packaging>war</packaging>

项目最终打包格式为.war

2.2创建webapp目录

F4 ->open moudle settings ->选择web创建webapp目录 ->"+"号web.xml放在webapp目录下


image

2.3添加springMVC依赖

 <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.1.6.RELEASE</version>
        </dependency>
    </dependencies>

3.配置文件

File->New->XML Configuration FLie->Spring Config(添加依赖后才能创建)
都放在resource文件夹下

3.1applicationContext.xml

spring的配置文件

  <context:component-scan base-package="com.zby" use-default-filters="true">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

扫描除controller之外的东西

3.2spring-servlet.xml

springMVC的配置文件

 <context:component-scan base-package="com.zby" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    <mvc:annotation-driven/>

扫描controller·

相关文章

网友评论

      本文标题:SSM框架搭建

      本文链接:https://www.haomeiwen.com/subject/knxtchtx.html