文档章节

Spring+SpringMVC+Mybatis+EasyUI古诗搜索系统(三--配置文件)

northsailor
 northsailor
发布于 2016/07/14 17:22
字数 859
阅读 2
收藏 0

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name></display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
   <!-- Spring前端控制器 -->
    <servlet>
        <servlet-name>SpringMVC</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>
                contextConfigLocation
            </param-name>
            <param-value>
                classpath:applicationContext.xml
            </param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>SpringMVC</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <!-- 使用Filter解决中文乱码问题 -->
    <filter>
        <filter-name>encodingFilter</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>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>  
</web-app>

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:util="http://www.springframework.org/schema/util"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
		http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

	<description>Spring公共配置</description>
	<!--=======================================1.配置数据源使用========================================== -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
		<property name="jdbcUrl"
			value="jdbc:mysql://localhost:3306/tang_poetry?useUnicode=true&amp;characterEncoding=utf-8">
		</property>
		<property name="user" value="root"></property>
		<property name="password" value="123456"></property>
	</bean>
	<!--========================================2.配置SqlSessionFactory===================================================== -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mapperLocations" value="classpath:com/jikexueyuan/entity/*.xml" />
	</bean>
	 <!--定义SqlSessionTemplate -->
    <bean id="sqlSessionTemplate" 
        class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0" ref="sqlSessionFactory"/>
    </bean>
	<!--========================================3. 配置MyBatis注解========================================================= -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.jikexueyuan.dao" />
		<property name="annotationClass" value="com.jikexueyuan.annotation.MyBatisRepository" />
	</bean>
	<!--=======================================4.开启注解扫描============================================================== -->
	<context:component-scan base-package="com.jikexueyuan" />
	<!--=======================================5. 开启RequestMapping注解 =================================================== -->
	<mvc:annotation-driven />
	<!--========================================6. 处理请求转发=============================================================== -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsp" />
	</bean>
<!--========================================7. 声明方面组件============================================================== -->
	<bean id="operateLogger" class="com.jikexueyuan.aspect.OperateLogger" />

	<!--========================================8. 配置AOP ===================================================================== -->
	<aop:config>
		<aop:aspect ref="operateLogger">
			<aop:before method="log1" pointcut="within(com.jikexueyuan.controller..*)" />
		</aop:aspect>
		<aop:aspect ref="operateLogger">
			<aop:around method="log2" pointcut="within(com.jikexueyuan.controller..*)" />
		</aop:aspect>
		<aop:aspect ref="operateLogger">
			<aop:after-throwing method="log3" throwing="e"
				pointcut="within(com.jikexueyuan.controller..*)" />
		</aop:aspect>
	</aop:config>
	<!-- 开启AOP注解扫描 -->
	<aop:aspectj-autoproxy proxy-target-class="true" />
	<!--=========================================9. 声明事务管理组件========================================================== -->
	<bean id="txManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- 开启事务注解扫描 -->
	<tx:annotation-driven transaction-manager="txManager"
		proxy-target-class="true" />
</beans>

lofback.xml

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

   <!-- 时间滚动输出 level为 DEBUG 日志 -->
    <appender name="file-debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY </onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/debug.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
 
    <!-- 时间滚动输出 level为 INFO 日志 -->
    <appender name="file-info" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY </onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/info.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    
    <!-- 时间滚动输出 level为 INFO 日志 -->
    <appender name="file-error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY </onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/error.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    
    <!-- 很多人使用Mybatis的时候,控制台不能输出SQL语句,造成调试困难。只需要让DAO层的日志级别调整为DEBUG就可以了 -->
    <logger name="com.jikexueyuan.dao" level="DEBUG" />

    <!-- 指定项目可输出的最低级别日志 -->
    <root level="INFO">
        <appender-ref ref="console" />
        <appender-ref ref="file-debug" />
        <appender-ref ref="file-info" />
        <appender-ref ref="file-error" />
    </root>
</configuration>

 

© 著作权归作者所有

共有 人打赏支持
northsailor
粉丝 1
博文 5
码字总数 3598
作品 0
兰州
程序员
私信 提问
ZHENFENGSHISAN/perfect-ssm

Quick Start 项目简介 ssm系列 ssm-demo:Spring+SpringMVC+Mybatis+easyUI整合 perfect-ssm:RESTful API+redis缓存 ssm-cluster:前后端分离+集群部署 ssm-dubbo:dubbo服务化 ssm-micro-se......

ZHENFENGSHISAN
2017/09/18
0
0
Spring+mybatis的一个简单例子

一、eclipse新建java项目取名SpringTest 二、导入sping,mybatis,jdbc(这里用postgresql)包到构建路径 三、在psql中建库、建表的脚本。 四、创建java类 student表对应的pojo对象 映射文件cn/...

wangxuwei
2016/01/09
744
0
window.location.hash解析

location对象:设置或获取当前URL的信息 使用location对象可以设置或返回URL中的一些信息,一个完整的URL地址的格式为: 协议://主机:端口/路径名称#hash标识?搜索条件 其 中,协议是URL的起...

aminqiao
2014/05/09
0
0
国内首个支持离线搜题软件--离线小搜

离线小搜(Offline-small-search) 离线搜索软件,现支持离线搜题,搜古诗文,搜开发文档,等等.可自行打包离线包. 国内首个支持离线搜题的软件. 功能及特点 离线全文检索,采用高度压缩打包的ZIM文...

zjzdy
2016/03/07
379
0
中华古典文集数据库 - chinese-poetry

最全的中华古典文集数据库, 包含5.5万首唐诗、26万首宋诗和2.1万首宋词. 唐宋两朝近1.4万古诗人, 和两宋时期1.5K词人. 数据来源于互联网. 为什么要做这个仓库? 古诗是中华民族乃至全世界的瑰...

匿名
11/14
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Ubuntu18.04 安装MySQL

1.安装MySQL sudo apt-get install mysql-server 2.配置MySQL sudo mysql_secure_installation 3.设置MySQL非root用户 设置原因:配置过程为系统root权限,在构建MySQL连接时出现错误:ERROR...

AI_SKI
今天
3
0
3.6 rc脚本(start方法) 3.7 rc脚本(stop和status方法) 3.8 rc脚本(以daemon方式启动)

3.6-3.7 rc脚本(start、stop和status方法) #!/usr/bin/env python# -*- coding: utf-8 -*-# [@Version](https://my.oschina.net/u/931210) : python 2.7# [@Time](https://my.oschina.......

隐匿的蚂蚁
今天
3
0
Cnn学习相关博客

CNN卷积神经网络原理讲解+图片识别应用(附源码) 笨方法学习CNN图像识别系列 深度学习图像识别项目(中):Keras和卷积神经网络(CNN) 卷积神经网络模型部署到移动设备 使用CNN神经网络进行...

-九天-
昨天
5
0
flutter 底部输入框 聊天输入框 Flexible

想在页面底部放个输入框,结果键盘一直遮住了,原来是布局问题 Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("评论"), ...

大灰狼wow
昨天
4
0
Kernel I2C子系统

备注:所有图片来源于网络 1,I2C协议: 物理拓扑: I2C总线由两根信号线组成,一条是时钟信号线SCL,一条是数据信号线SDA。一条I2C总线可以接多个设备,每个设备都接入I2C总线的SCL和SDA。I...

yepanl
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部