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

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

SSM框架配置文件詳解

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

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

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框架的基本配置文件。

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

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 老司机日日摸夜夜摸精品影院 | 欧美一区二区三区精品影视 | 大香伊人中文字幕精品 | 欧美最猛黑人xxxxx猛交 | 日批日韩在线观看 | 波霸欧美性猛交xxxxxx | 免费国产成人高清在线看软件 | jizzjizz中国护士第一次 | 久久青青成人亚洲精品 | 亚洲成人精品久久 | 中文字幕在线观看一区 | 狠狠干夜夜 | 欧美在线视频免费播放 | 久久精品国产一区二区三区不卡 | 久久青草免费97线频观 | 风流放荡的艳妇小说 | eee在线播放成人免费 | 国产精品天干天干在线综合 | 美女肥胖大bbbb | 一级毛片私人影院 | 欧美啊v在线观看 | 日本vs欧美一区二区三区 | 韩国理伦片在线理伦韩国 | 亚洲第一看片 | 日韩美女一级片 | 中文字幕天堂 | 在线播放a | 久草视频在线资源站 | 国产欧美乱码在线看 | 日本黄色免费一级片 | 老人与老人免费a级毛片 | 国产综合在线播放 | 欧美成人午夜免费完成 | 欧美成人免费观看 | 成年人免费观看视频网站 | 色午夜影院 | 秋霞影视伦理手机在线观看 | 久久综合五月天婷婷伊人 | 亚洲不卡视频 | 国内精品 大秀视频 日韩精品 | 日本免费不卡视频一区二区三区 |