SSM框架搭建

SSM框架搭建

1.新建maven工程

File->New->Project->Maven

2.配置pom.xml

2.1

<packaging>war</packaging>

項(xiàng)目最終打包格式為.war

2.2創(chuàng)建webapp目錄

F4 ->open moudle settings ->選擇web創(chuàng)建webapp目錄 ->"+"號(hào)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(添加依賴后才能創(chuàng)建)
都放在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·

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容