大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 SSM框架配置文件詳解

SSM框架配置文件詳解

更新時間:2022-05-18 09:55:21 來源:動力節點 瀏覽1879次

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

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文件的監聽器 -->
    <上下文參數>
        <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 >
        <初始化參數>
            <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前端核心控制器-->
    <小服務程序>
        <servlet 名稱>crm</servlet 名稱>
        <servlet- class >org.springframework.web.servlet.DispatcherServlet</servlet- class >
        <初始化參數>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-config.xml</param-value>
        </init-param>
        <!-- 配置服務器啟動后立即加載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
    網址: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"/>
    <!-- 注解驅動:配置處理器映射器和適配器 -->
    <mvc:annotation-driven/>
    <!--配置靜態資源的訪問映射,此配置中的文件不會被前端控制器攔截-->
    <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
        網址: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"/>
    <!--配置數據源-->
    <bean id="dataSource"類="org.apache.commons.dbcp2.BasicDataSource">
        <!--數據庫驅動器-->
        <property name="driverClassName" value="${jdbc.driver}"/>
        <!--連接數據庫的URL-->
        <property name="url" value="${jdbc.url}"/>
        <!--連接數據庫的用戶名-->
        <property name="username" value="${jdbc.username}"/>
        <!--連接數據庫的密碼-->
        <property name="password" value="${jdbc.password}"/>
        <!--最大連接數-->
        <property name="maxTotal" value="${jdbc.maxTotal}"/>
        <!--最大空閑數-->
        <property name="maxIdle" value="${jdbc.maxIdle}"/>
        <!--初始連接號-->
        <property name="initialSize" value="${jdbc.initialSize}"/>
    </豆>
    <!-- 事務管理器,依賴于數據源 -->
    <bean id="transactionManager"類="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </豆>
    <!--注意事項-->
    <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">
        <!--注入數據源-->
        <property name="dataSource" ref="dataSource"/>
        <!--指定mapper文件的位置-->
        <property name="mapperLocations" value="classpath:mybatis/sqlmap/*.xml"/>
        <!--指定MyBatis的核心配置文件-->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
    </豆>
    <!-- 接口開發,掃描com.itheima.core.dao包,可以掃描到這個包里寫的接口 -->
    <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 =錯誤,標準輸出
# MyBatis 日志配置...
log4j.logger.com.ma.core =調試
# 控制臺輸出...
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框架的基本配置文件。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 日日碰夜夜爽 | 老头做爰xxxx视频 | 亚洲第一成年人网站 | 综合在线视频精品专区 | 国产小呦 | 黑人边吃奶边扎下面激情视频 | 欧美精品一区二区三区观 | 日韩av片免费播放 | 久久久久国产午夜 | 美日韩黄色片 | 高清影院|精品秒播3 | 香蕉免费在线视频 | 久久久国产精品免费看 | 国产福利视频在线 | 亚洲欧美日韩高清中文在线 | 欧美在线成人免费国产 | 亚洲一区二区三区精品视频 | 天天天干干干 | 亚洲欧美精品在线 | 国内久久久久影院精品 | 四虎影院黄色 | 亚洲视频aaa | 久久精品国产第一区二区 | 亚洲精品在线看 | 亚洲视频污| 精品乱人伦一区二区 | 亚洲国产精品yw在线观看 | 91精品刘玥在线播放 | 欧美性猛交ⅹxxx乱大交按摩 | 中国大乳久久 | 久久国产精品高清一区二区三区 | 四虎影在永久地址在线观看 | 一区二区国产精品 | 91成人免费在线视频 | 亚洲欧美综合区自拍另类 | 国产免费一级片 | 一区二区中文字幕亚洲精品 | 久久99精品久久久久久久不卡 | 国产高清亚洲 | 亚洲欧美精品网站在线观看 | 一级毛片免费的 |