赞
踩
- mysql.driver=com.mysql.jdbc.Driver
- mysql.url=jdbc:mysql://localhost:3306/ssm?characterEncoding=utf8
- mysql.username=root
- mysql.password=root
- #############################################################################################
- log4j.rootCategory=error, console, logfile
- #############################################################################################
- #log4j.logger.com.zer.mapper=debug, console, logfile
- log4j.logger.com.zer.mapper=debug
- #############################################################################################
- #设置输出到控制台
- log4j.appender.console=org.apache.log4j.ConsoleAppender
- #设置打印的日志级别
- log4j.appender.console.Threshold=debug
- #设置所有消息被立即输出
- log4j.appender.console.ImmediateFlush = true
- #设置布局模式
- log4j.appender.console.layout=org.apache.log4j.PatternLayout
- #设置打印的日志格式
- log4j.appender.console.layout.ConversionPattern=[%p %d{yyyy-MM-dd HH:mm:ss}] %c{3} %m%n
- #############################################################################################
- #设置输出到文件
- log4j.appender.logfile=org.apache.log4j.FileAppender
- #设置输出到指定位置
- log4j.appender.logfile.File=d:/axis.log
- #设置追加到文件后面
- log4j.appender.logfile.Append=true
- #设置布局模式
- log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
- #设置打印的日志格式
- log4j.appender.logfile.layout.ConversionPattern=[%p %d{yyyy-MM-dd HH:mm:ss}] %c{3} %m%n
- #############################################################################################
- #日志等级
- #ALL/DEBUG/INFO/WARN/ERROR/FATAL/OFF
- #配置日志信息输出目的地[appender]
- #log4j.appender.自定义名称
- #输出到控制台:org.apache.log4j.ConsoleAppender
- #输出到文件:org.apache.log4j.FileAppender
- #配置日志信息的输出格式[Layout]
- #灵活地指定布局模式:org.apache.log4j.PatternLayout
- <?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: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.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd"
- >
-
- <!--配置 配置文件扫描-->
- <context:property-placeholder location="classpath:db.properties"/>
- <!--配置 注解扫描-->
- <context:component-scan base-package="com.zer.service.impl"/>
- <!--配置 数据库 bean-->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="${mysql.driver}"/>
- <property name="url" value="${mysql.url}"/>
- <property name="username" value="${mysql.username}"/>
- <property name="password" value="${mysql.password}"/>
- </bean>
- <!--配置 工厂 bean-->
- <bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- </bean>
- <!--配置 mapper 扫描 bean-->
- <bean id="mapper" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="sqlSessionFactoryBeanName" value="factory"/>
- <property name="basePackage" value="com.zer.mapper"/>
- </bean>
- <!--配置 事务 bean-->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"/>
- </bean>
- <!--配置 事务 方法-->
- <tx:advice id="advice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="ins*"/>
- <tx:method name="del*"/>
- <tx:method name="up*"/>
- <tx:method name="sel*" read-only="true"/>
- </tx:attributes>
- </tx:advice>
- <!--配置 事务 切面-->
- <aop:config>
- <aop:pointcut id="my" expression="execution(* com.zer.service.impl.*.*(..))"/>
- <aop:advisor advice-ref="advice" pointcut-ref="my"/>
- </aop:config>
-
- </beans>
- <?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: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.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
- <!--配置 注解扫描-->
- <context:component-scan base-package="com.zer.controller"/>
- <!--配置 注解解析器-->
- <mvc:annotation-driven/>
- <!--配置 静态资源放行-->
- <mvc:resources mapping="/js/**" location="/js/"/>
- <mvc:resources mapping="/css/**" location="/css/"/>
- <mvc:resources mapping="/images/**" location="/images/"/>
- <!--配置 自定义视图解析器 bean-->
- <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>
- <!--配置 文件上传解析 bean-->
- <bean id="commonsMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
-
- </beans>
- <?xml version="1.0" encoding="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"
- version="3.1">
- <!--配置 Spring配置文件-->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:applicationcontext.xml</param-value>
- </context-param>
- <!--配置监听器-->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
-
- <!--配置 SpringMVC的Servlet-->
- <servlet>
- <servlet-name>mvc</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <!--配置 SpringMVC配置文件-->
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:springmvc.xml</param-value>
- </init-param>
- <!--配置 服务器启动完就初始化完成-->
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>mvc</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <!--配置 编码过滤器-->
- <filter>
- <filter-name>code</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>code</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- </web-app>
欢迎各位一起交流~~~~~
有帮助的话点点三连哦~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。