黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

專注Java教育14年 全國(guó)咨詢/投訴熱線:400-8080-105
動(dòng)力節(jié)點(diǎn)LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁(yè) hot資訊 SSM框架配置文件詳解

SSM框架配置文件詳解

更新時(shí)間:2022-05-18 09:55:21 來(lái)源:動(dòng)力節(jié)點(diǎn) 瀏覽1896次

學(xué)習(xí)框架的時(shí)候,一開始最煩的就是一些配置文件,有很多東西需要配置。

Web.xml 文件

<?xml 版本="1.0" 編碼="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"
         版本="3.1">
    <!-- 配置加載Spring文件的監(jiān)聽器 -->
    <上下文參數(shù)>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <聽眾>
        <listener- class >org.springframework.web.context.ContextLoaderListener</listener- class >
    </listener>
    <!-- 編碼過濾器-->
    <過濾器>
        <filter-name>編碼</filter-name>
        <filter- class >org.springframework.web.filter.CharacterEncodingFilter</filter- class >
        <初始化參數(shù)>
            <param-name>編碼</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </過濾器>
    <過濾器映射>
        <filter-name>編碼</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <!-- 配置Spring MVC前端核心控制器-->
    <小服務(wù)程序>
        <servlet 名稱>crm</servlet 名稱>
        <servlet- class >org.springframework.web.servlet.DispatcherServlet</servlet- class >
        <初始化參數(shù)>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-config.xml</param-value>
        </init-param>
        <!-- 配置服務(wù)器啟動(dòng)后立即加載Spring MVC配置文件-->
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet 映射>
        <servlet 名稱>crm</servlet 名稱>
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>    
    <歡迎文件列表>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Springmvc的配置文件springmvc-config.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:mvc ="http://www .springframework.org/schema/mvc" 
       xmlns:context ="http://www.springframework.org/schema/context" 
       xmlns:aop ="http://www.springframework.org/schema/aop" 
       xmlns:tx ="http://www.springframework.org/schema/tx" 
       xsi:schemaLocation ="http://www.springframework.org/schema/beans
    網(wǎng)址:www.springframework.org/schema/beans/spring-beans-4.3.xsd 
    http:www.springframework.org/schema/mvc 
    http:www.springframework.org/schema/mvc/spring-mvc-4.3.xsd 
    http:www.springframework.org/schema/context 
    http:www.springframework.org/schema/context/spring-context-4.3.xsd 
    http:www.springframework.org/schema/aop 
    http:www.springframework.org/schema/aop/spring-aop-4.3.xsd 
    http:www.springframework.org/schema/tx 
    http:www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <!-- 加載屬性文件 -->
    <context:property-placeholder location="classpath:resource.properties"/>
    <!-- 配置掃描儀-->
    <context:component-scan base- package ="com.ma.core.web.controller"/>
    <!-- 注解驅(qū)動(dòng):配置處理器映射器和適配器 -->
    <mvc:annotation-driven/>
    <!--配置靜態(tài)資源的訪問映射,此配置中的文件不會(huì)被前端控制器攔截-->
    <mvc:resources mapping="/js/**" location="/js/"/>
    <mvc:resources mapping="/css/**" location="/css/"/>
    <mvc:resources mapping="/fonts/**" location="/fonts/"/>
    <mvc:resources mapping="/images/**" location="/images/"/>
    <!-- 配置視圖解釋器ViewResolver -->
    <bean id="jspViewResolver"類="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </豆>
    <!--配置攔截器-->
    <mvc:攔截器>
        <mvc:攔截器>
            <mvc:mapping path="/**"/>
            <bean class ="com.ma.core.interceptor.LoginInterceptor"/>
        </mvc:攔截器>
    </mvc:攔截器>
</beans>

ApplicationContext.xml 文件

<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:mvc ="http://www .springframework.org/schema/mvc" 
       xmlns:context ="http://www.springframework.org/schema/context" 
       xmlns:aop ="http://www.springframework.org/schema/aop" 
       xmlns:tx ="http://www.springframework.org/schema/tx" 
       xsi:schemaLocation ="http://www.springframework.org/schema/beans
        網(wǎng)址:www.springframework.org/schema/beans/spring-beans-4.3.xsd 
        http:www.springframework.org/schema/mvc 
        http:www.springframework.org/schema/mvc/spring-mvc-4.3.xsd 
        http:www.springframework.org/schema/context 
        http:www.springframework.org/schema/context/spring-context-4.3.xsd 
        http:www.springframework.org/schema/aop 
        http:www.springframework.org/schema/aop/spring-aop-4.3.xsd 
        http:www.springframework.org/schema/tx 
        http:www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <!--讀取 db.properties-->
    <context:property-placeholder location="classpath:db.properties"/>
    <!--配置數(shù)據(jù)源-->
    <bean id="dataSource"類="org.apache.commons.dbcp2.BasicDataSource">
        <!--數(shù)據(jù)庫(kù)驅(qū)動(dòng)器-->
        <property name="driverClassName" value="${jdbc.driver}"/>
        <!--連接數(shù)據(jù)庫(kù)的URL-->
        <property name="url" value="${jdbc.url}"/>
        <!--連接數(shù)據(jù)庫(kù)的用戶名-->
        <property name="username" value="${jdbc.username}"/>
        <!--連接數(shù)據(jù)庫(kù)的密碼-->
        <property name="password" value="${jdbc.password}"/>
        <!--最大連接數(shù)-->
        <property name="maxTotal" value="${jdbc.maxTotal}"/>
        <!--最大空閑數(shù)-->
        <property name="maxIdle" value="${jdbc.maxIdle}"/>
        <!--初始連接號(hào)-->
        <property name="initialSize" value="${jdbc.initialSize}"/>
    </豆>
    <!-- 事務(wù)管理器,依賴于數(shù)據(jù)源 -->
    <bean id="transactionManager"類="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </豆>
    <!--注意事項(xiàng)-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:屬性>
            <!--通信行為-->
            <tx:method name="save*" 傳播="REQUIRED"/>
            <tx:method name="插入*" 傳播="REQUIRED"/>
            <tx:method name="add*" 傳播="REQUIRED"/>
            <tx:method name="create*" 傳播="REQUIRED"/>
            <tx:method name="delete*" 傳播="REQUIRED"/>
            <tx:method name="update*" 傳播="REQUIRED"/>
            <tx:method name="find*" 傳播="SUPPORTS" 只讀="true"/>
            <tx:method name="select*" 傳播="SUPPORTS" 只讀="true"/>
            <tx:method name="get*" 傳播="SUPPORTS" 只讀="true"/>
        </tx:屬性>
    </tx: 建議>
    <!--切面條-->
    <aop:配置>
        <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.ma.core.service.*.*(..))"/>
    </aop:config>
    <!--配置MyBatis工廠SqlSessionFactory-->
    <bean id="sqlSessionFactory" class ="org.mybatis.spring.SqlSessionFactoryBean">
        <!--注入數(shù)據(jù)源-->
        <property name="dataSource" ref="dataSource"/>
        <!--指定mapper文件的位置-->
        <property name="mapperLocations" value="classpath:mybatis/sqlmap/*.xml"/>
        <!--指定MyBatis的核心配置文件-->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
    </豆>
    <!-- 接口開發(fā),掃描com.itheima.core.dao包,可以掃描到這個(gè)包里寫的接口 -->
    <bean類="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.ma.core.dao"/>
    </豆>
    <!-- 配置掃描@Service注解-->
    <context:component-scan base- package ="com.ma.core.service"/>
</beans>

Mybatis 配置文件 mybatis-config.xml

<?xml 版本="1.0" 編碼="UTF-8" ?>
<!DOCTYPE 配置 PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<配置>
    <!-- 別名定義-->
    <類型別名>
        <包名="com.ma.core.po"/>
    </typeAliases>
</配置>

Db.properties 文件

jdbc.driver= com.mysql.jdbc.Driver
jdbc.url =jdbc:mysql:localhost:3306/test 
jdbc.username= root
jdbc.password = 
jdbc.maxTotal =30 
jdbc.maxIdle =10 
jdbc.initialSize =5

Log4j.properties 文件

# 全局日志配置
log4j.rootLogger =錯(cuò)誤,標(biāo)準(zhǔn)輸出
# MyBatis 日志配置...
log4j.logger.com.ma.core =調(diào)試
# 控制臺(tái)輸出...
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =%5p [%t] - %m%n

以上是SSM框架的基本配置文件。

提交申請(qǐng)后,顧問老師會(huì)電話與您溝通安排學(xué)習(xí)

  • 全國(guó)校區(qū) 2025-05-15 搶座中
  • 全國(guó)校區(qū) 2025-06-05 搶座中
  • 全國(guó)校區(qū) 2025-06-26 搶座中
免費(fèi)課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 伦理片免费观看 | 国产成人精品福利网站在线 | 影音先锋国产系列精品 | 操操操日日日 | 国产一区在线免费观看 | 免费人欧美成又黄又爽的视频 | 亚洲视频在线一区二区 | 国产97色在线 | 亚洲 | 日韩高清特级特黄毛片 | 在线欧美69v免费观看视频 | 一级爱一级做a性视频 | 国产午夜视频在永久在线观看 | 84pao国产成视频免费播放 | 天天干天天摸 | 亚洲人成毛片线播放 | 日本一区二区视频在线观看 | 99视频在线观看免费 | 人人干人人玩 | 亚洲三级a | 高清一区在线 | 九九精品视频一区在线 | 亚洲黄色免费网址 | 国产成人区 | 色吧首页 | 免费观看污污视频 | 国产综合激情在线亚洲第一页 | 五月婷香 | 亚洲三级视频 | 黄色短视屏 | 噜噜噜天天躁狠狠躁夜夜精品 | 日本全身露裸无遮挡黄漫画 | 免费三级黄色 | 国产精品久久久久久久人热 | 国产精品1| 日韩在线视频精品 | 天堂网在线www资源网 | 天天看天天射天天视频 | 国产成人啪精品视频免费网 | 成人免费午间影院在线观看 | 毛片在线免费视频 | 色黄在线观看 |