SSM配置文件

                                        #SSM配置文件

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
        <!--spring框架的配置文件-->
        <!--1配置数据源-->
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
            <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
            <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/>
            <property name="username" value="zhangshuai"/>
            <property name="password" value="zs170816"/>
        </bean>
        <!--2通过数据源、mybatis、和具体的mapper映射文件作为参数,配置封装好的SqlSessionFactoryBean-->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"></property>
            <property name="configLocation" value="classpath:mybatis-config.xml"></property>
            <property name="mapperLocations" value="classpath*:cn/goods/dao/*.xml"></property>
        </bean>
        <!--2批量为mapper文件对应的接口进行注入-->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="cn.goods.dao"></property>
        </bean>
        <!--4注解注入-->
        <!--注解扫描的包-->
        <context:component-scan base-package="cn.goods.controller,cn.goods.service.impl"></context:component-scan>
        <!-- 5事务配置-->
        <!--事务配置-->
        <bean id="tx" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"></property>
        </bean>
        <!--事务切面-->
        <aop:config>
            <aop:pointcut id="pointcutId" expression="execution(* cn.goods.dao.*..*(..))"/>
            <aop:advisor advice-ref="txAdisor" pointcut-ref="pointcutId"/>
        </aop:config>
        <!--事务传播机制-->
        <tx:advice id="txAdisor" transaction-manager="tx">
            <tx:attributes>
                <tx:method name="select*" propagation="SUPPORTS"/>
                <tx:method name="update*" propagation="REQUIRED"/>
                <tx:method name="delete*" propagation="REQUIRED"/>
                <tx:method name="insert*" propagation="REQUIRED"/>
                <tx:method name="*" propagation="REQUIRED" read-only="false"/>
            </tx:attributes>
        </tx:advice>
        <!--6注解定义切面-->
    <!--    <aop:aspectj-autoproxy/>-->

        <!--  6-2配置文件定义切面   -->
        <!--<bean id="LoggerAOP" class="cn.smbms.aop.LoggerAOP"></bean>

        <aop:config>
            <aop:pointcut id="pointcutId" expression="execution(* cn.smbms.biz.*..*(..))"/>
            <aop:aspect ref="LoggerAOP">
                <aop:before method="loggerBefore" pointcut-ref="pointcutId"></aop:before>
                <aop:after-returning method="afterRunning" pointcut-ref="pointcutId" returning="object"></aop:after-returning>
                <aop:after-throwing method="throwLogger" pointcut-ref="pointcutId" throwing="runtimeException"></aop:after-throwing>
                <aop:around method="around" pointcut-ref="pointcutId" ></aop:around>
                <aop:after method="after" pointcut-ref="pointcutId" ></aop:after>
            </aop:aspect>
        </aop:config>-->
</beans>

applicationContext-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
    <!--spring mvc的配置文件-->
    <!--1注解的包-->
    <context:component-scan base-package="cn.goods.controller"></context:component-scan>

    <!--2注解方式mvc-->
    <mvc:annotation-driven/>

    <!--3配置视图解析器-->
    <!--页面前缀和页面后缀-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/pages/"></property>
        <property name="suffix" value=".html"></property>
    </bean>

    <!--4配置文件上传所需配置-->
    <!-- id属性必须是这样的-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10240000"></property>
        <property name="defaultEncoding" value="utf-8"></property>
    </bean>

    <!--5配置静态文件-->
    <!--配置到具体的静态文件-->
    <!--mapping是访问路径, location是本地具体路径-->
    <mvc:resources mapping="/static/**" location="/static/"></mvc:resources>
    <mvc:resources mapping="/static/images/**" location="/static/images/"></mvc:resources>
    <mvc:resources mapping="/static/js/**" location="/static/js/"></mvc:resources>
    <mvc:resources mapping="/static/css/**" location="/static/css/"></mvc:resources>
    <mvc:resources mapping="/pages/**" location="/pages/"></mvc:resources>
</beans>

mybatis-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE configuration
                PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
                "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

</configuration>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_4_0.xsd"
           version="3.0">

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <!--2配置spring框架的配置文件-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext.xml</param-value>
    </context-param>
    <!--3对应spring mvc的servlet配置-->
    <servlet>
        <servlet-name>Dispatcherservlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:applicationContext-mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Dispatcherservlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>


    <!--字符集配置-->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

log4j.properties

log4j.rootLogger=DEBUG,CONSOLE,file
#log4j.rootLogger=ERROR,ROLLING_FILE
log4j.logger.cn.smbms.dao=debug
log4j.logger.com.ibatis=debug 
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug 
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug 
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug 
log4j.logger.java.sql.Connection=debug 
log4j.logger.java.sql.Statement=debug 
log4j.logger.java.sql.PreparedStatement=debug 
log4j.logger.java.sql.ResultSet=debug 
log4j.logger.org.tuckey.web.filters.urlrewrite.UrlRewriteFilter=debug

######################################################################################
# Console Appender  \u65e5\u5fd7\u5728\u63a7\u5236\u8f93\u51fa\u914d\u7f6e
######################################################################################
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=error
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern= [%p] %d %c - %m%n


######################################################################################
# DailyRolling File  \u6bcf\u5929\u4ea7\u751f\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u683c\u5f0f:log2009-09-11
######################################################################################
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern=yyyy-MM-dd
log4j.appender.file.File=log.log
log4j.appender.file.Append=true
log4j.appender.file.Threshold=error
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-M-d HH:mm:ss}%x[%5p](%F:%L) %m%n


log4j.logger.com.opensymphony.xwork2=error  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值