spring开发需要的配置文件
1,applicationContext-dao.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 数据库连接池 --> <!-- 加载配置文件 --> <context:property-placeholder location="classpath:properties/*.properties" /> <!-- 数据库连接池 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="driverClassName" value="${jdbc.driver}" /> <property name="maxActive" value="10" /> <property name="minIdle" value="5" /> </bean> <!-- 让spring管理sqlsessionfactory 使用mybatis和spring整合包中的 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 数据库连接池 --> <property name="dataSource" ref="dataSource" /> <!-- 加载mybatis的全局配置文件 --> <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /> </bean> <!-- 配置mapper文件的扫描器 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="priv.lirenhe.项目简称.dao.*" /><!-- .*指代dao下的包,而不是文件java或者xml --> </bean> </beans> |
2,applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 包扫描器,扫描@Service注解 --> <context:component-scan base-package="priv.lirenhe.项目简称.service"></context:component-scan> </beans> |
3,applicationContext-trans.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!-- 数据源 --> <property name="dataSource" ref="dataSource" /> </bean> <!-- 通知 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- 传播行为 --> <tx:method name="save*" propagation="REQUIRED" /><!-- "REQUIRED" 有事务就在当前事务执行,没事务就开启事务 --> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="find*" propagation="SUPPORTS" read-only="true" /><!-- "SUPPORTS" 有事务就在当前事务执行,没事务就不开启事务 --> <tx:method name="select*" propagation="SUPPORTS" read-only="true" /> <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> </tx:attributes> </tx:advice> <!-- 切面 --> <aop:config> <aop:advisor advice-ref="txAdvice" pointcut="execution(* priv.lirenhe.项目简称.service.impl.*.*(..))" /><!-- 第一个*:任意返回值 第二个*:任意返回包 第三个*:任意方法名,(..):任意参数--> </aop:config> </beans> |
4,springmvc.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- 必须有带mvc的 --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 配置包扫描器 --> <context:component-scan base-package="priv.lirenhe.项目简称.controller"></context:component-scan> <!-- 配置注解驱动 --> <mvc:annotation-driven/> <!-- 视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans> |
5,db.properties
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/数据库名?characterEncoding=utf-8 jdbc.username=root jdbc.password=123 |
6,sqlMapConfig.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> <settings> <setting name="cacheEnabled" value="true" /> <setting name="lazyLoadingEnabled" value="true" /> <setting name="multipleResultSetsEnabled" value="true" /> <setting name="useColumnLabel" value="true" /> <setting name="useGeneratedKeys" value="false" /> <setting name="autoMappingBehavior" value="PARTIAL" /> <setting name="autoMappingUnknownColumnBehavior" value="WARNING" /> <setting name="defaultExecutorType" value="SIMPLE" /> <setting name="defaultStatementTimeout" value="100" /> <setting name="defaultFetchSize" value="100" /> <setting name="safeRowBoundsEnabled" value="false" /> <setting name="mapUnderscoreToCamelCase" value="false" /> <setting name="localCacheScope" value="SESSION" /> <setting name="jdbcTypeForNull" value="OTHER" /> <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" /> <setting name="logImpl" value="SLF4J" /> <!-- 打印查询语句 --> <!-- <setting name="logImpl" value="STDOUT_LOGGING" /> --> </settings> </configuration> |
7,log4j.properties:
### Log4j\u914D\u7F6E ### ### \u4E0ESpring\u7ED3\u5408\u9700\u8981\u5728web.xml\u4E2D\u6307\u5B9A\u6B64\u6587\u4EF6\u4F4D\u7F6E\uFF0C\u5E76\u6DFB\u52A0\u76D1\u542C\u5668 ### #\u5B9A\u4E49log4j\u7684\u8F93\u51FA\u7EA7\u522B\u548C\u8F93\u51FA\u76EE\u7684\u5730\uFF08\u76EE\u7684\u5730\u53EF\u4EE5\u81EA\u5B9A\u4E49\u540D\u79F0\uFF0C\u548C\u540E\u9762\u7684\u5BF9\u5E94\uFF09 #[ level ] , appenderName1 , appenderName2 log4j.rootLogger=DEBUG,console,file #-----------------------------------# #1 \u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0 log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.Target = System.out log4j.appender.console.Threshold=DEBUG ####\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F ### #%c: \u8F93\u51FA\u65E5\u5FD7\u4FE1\u606F\u6240\u5C5E\u7684\u7C7B\u76EE\uFF0C\u901A\u5E38\u5C31\u662F\u6240\u5728\u7C7B\u7684\u5168\u540D #%m: \u8F93\u51FA\u4EE3\u7801\u4E2D\u6307\u5B9A\u7684\u6D88\u606F,\u4EA7\u751F\u7684\u65E5\u5FD7\u5177\u4F53\u4FE1\u606F #%n: \u8F93\u51FA\u4E00\u4E2A\u56DE\u8F66\u6362\u884C\u7B26\uFF0CWindows\u5E73\u53F0\u4E3A"/r/n"\uFF0CUnix\u5E73\u53F0\u4E3A"/n"\u8F93\u51FA\u65E5\u5FD7\u4FE1\u606F\u6362\u884C log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%c]-%m%n #-----------------------------------# #2 \u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6 log4j.appender.file = org.apache.log4j.RollingFileAppender #\u65E5\u5FD7\u6587\u4EF6\u8F93\u51FA\u76EE\u5F55 log4j.appender.file.File=log/tibet.log #\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F log4j.appender.file.MaxFileSize=10mb ###\u8F93\u51FA\u65E5\u5FD7\u4FE1\u606F### #\u6700\u4F4E\u7EA7\u522B log4j.appender.file.Threshold=ERROR log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[%p][%d{yy-MM-dd}][%c]%m%n #4 mybatis \u663E\u793ASQL\u8BED\u53E5\u90E8\u5206 log4j.logger.org.mybatis=DEBUG #log4j.logger.cn.tibet.cas.dao=DEBUG #log4j.logger.org.mybatis.common.jdbc.SimpleDataSource=DEBUG# #log4j.logger.org.mybatis.common.jdbc.ScriptRunner=DEBUG# #log4j.logger.org.mybatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG# #log4j.logger.java.sql.Connection=DEBUG log4j.logger.java.sql=DEBUG log4j.logger.java.sql.Statement=DEBUG log4j.logger.java.sql.ResultSet=DEBUG log4j.logger.java.sql.PreparedStatement=DEBUG |
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- 要调用的工作类 --> <bean id="Compare" class="具体调用的类.Compare"></bean> <!-- 定义调用对象和调用对象的方法 doTask--> <bean id="doTask_Compare" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- 调用的类 --> <property name="targetObject"> <ref bean="Compare"/> </property> <!-- 调用类中的方法 --> <property name="targetMethod"> <value>toCompare</value> </property> </bean> <!-- 定义触发时间 doTime --> <bean id="doTime01" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"> <ref bean="doTask_Compare"/> </property> <!-- cron表达式 --> <property name="cronExpression"> <!-- 每天凌晨1点执行一次--> <value>00 30 00 * * ?</value><!-- 00 0/30 * * * ? --> </property> </bean> <!-- <bean id="doTime02" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"> <ref bean="doTask_Compare"/> </property> cron表达式 <property name="cronExpression"> 每隔10秒执行一次 <value>00 0/30 * * * ?</value>00 30 12 * * ? </property> </bean> --> <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 --> <bean id="startQuertz" lazy-init="true" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="doTime01"/> <!-- <ref bean="doTime02"/> --> </list> </property> </bean> </beans> |
9,generatorConfig.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <classPathEntry location="E:\WorkSpace04\项目名\webapp\WEB-INF\lib\mysql-connector-java-5.1.30.jar" /> <context id="MySQL"> <commentGenerator> <property name="suppressDate" value="true" /> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://" userId="" password="" /> <javaModelGenerator targetPackage="domain的所在包domain.mysql" targetProject="项目名" /> <sqlMapGenerator targetPackage="mapper文件生成放到的路径.dao.mysql.mapper" targetProject="项目名" /> <javaClientGenerator targetPackage=".dao.mysql" implementationPackage="dao.mysql.impl" targetProject="项目名" type="XMLMAPPER" /> <table schema="schema名" tableName="表名" domainObjectName="pojo类名" enableDeleteByExample="false" enableDeleteByPrimaryKey="false" enableInsert="false" enableUpdateByExample="false" enableUpdateByPrimaryKey="false"> <columnOverride column="DOCID" property="docId" /> <columnOverride column="UUID" property="uuid" /> <columnOverride column="DOCTITLE" property="docTitle" /> <columnOverride column="DOCHTMLCON" property="docHtmlContent" /> <columnOverride column="PAGE_TIME" property="pageTime" /> <columnOverride column="DOCCHANNEL" property="docChannel" /> <columnOverride column="AREA" property="area" /> <columnOverride column="PROVINCE" property="province" /> <columnOverride column="CITY" property="city" /> <columnOverride column="DISTRICT" property="district" /> <columnOverride column="INFO_TYPE" property="infoType" /> <columnOverride column="INDUSTRY" property="industry" /> <columnOverride column="DOCVERSION" property="docVersion" /> <columnOverride column="DOCTYPE" property="docType" /> <columnOverride column="DOCSOURCE" property="docSource" /> <columnOverride column="DOCSECURITY" property="docSecurity" /> <columnOverride column="DOCSTATUS" property="docStatus" /> <columnOverride column="DOCKEYWORDS" property="docKeywords" /> <columnOverride column="DOCRELWORDS" property="docRelwords" /> <columnOverride column="CRUSER" property="crUser" /> <columnOverride column="CRTIME" property="crTime" /> <columnOverride column="TEMPLATEID" property="templateId" /> <columnOverride column="DOCNO" property="docNo" /> <columnOverride column="HITSCOUNT" property="hitsCount" /> <columnOverride column="OPERTIME" property="operTime" /> <columnOverride column="OPERUSER" property="operUser" /> <columnOverride column="SITEID" property="siteId" /> <columnOverride column="PUBLISHTIME" property="publishTime" /> <columnOverride column="DOWNSCOUNT" property="downsCount" /> <columnOverride column="AUDITSTATUS" property="auditStatus" /> <columnOverride column="AUDITDESC" property="auditDesc" /> <columnOverride column="AUDITTIME" property="auditTime" /> <columnOverride column="WEB_SOURCE_NO" property="webSourceNo" /> <columnOverride column="WEB_SOURCE_NAME" property="webSourceName" /> <columnOverride column="INFO_SOURCE" property="infoSource" /> <columnOverride column="PAGE_ATTACHMENTS" property="pageAttachments" /> <columnOverride column="QSTATUS" property="qStatus" /> <columnOverride column="QCODES" property="qCodes" /> <columnOverride column="ISDI" property="isdi" /> <columnOverride column="ISGC" property="isgc" /> <columnOverride column="BAGENCY" property="bAgency" /> <columnOverride column="NAME" property="name" /> <columnOverride column="QTYPE" property="qType" /> <columnOverride column="EXPIRY_DATE" property="expiryDate" /> <columnOverride column="QRANGE" property="qRange" /> <columnOverride column="RECORD_ID" property="recordId" /> <columnOverride column="SEAL_NO" property="sealNo" /> <columnOverride column="ID_NO" property="idNo" /> <columnOverride column="CSTATUS" property="cStatus" /> </table> </context> </generatorConfiguration> |
spring开发需要的配置文件的更多相关文章
- [Spring框架]Spring开发实例: XML+注解.
前言: 本文为自己学习Spring记录所用, 文章内容包括Spring的概述已经简单开发, 主要涉及IOC相关知识, 希望能够对新入门Spring的同学有帮助, 也希望大家一起讨论相关的知识. 一. ...
- 使用Spring开发第一个HelloWorld应用
http://www.importnew.com/13246.html 让我们用Spring来写第一个应用程序吧. 完成这一章要求: 熟悉Java语言 设置好Spring的环境 熟悉简单的Eclips ...
- 【Spring开发】—— Spring Core
原文:[Spring开发]-- Spring Core 前言 最近由于一些工作的需要,还有自己知识的匮乏再次翻开spring.正好整理了一下相关的知识,弥补了之前对spring的一些错误认知.这一次学 ...
- 转载 WebService 的CXF框架 WS方式Spring开发
WebService 的CXF框架 WS方式Spring开发 1.建项目,导包. 1 <project xmlns="http://maven.apache.org/POM/4.0 ...
- WebService 的CXF框架 WS方式Spring开发
1.建项目,导包. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...
- 搭建Spring开发环境并编写第一个Spring小程序
搭建Spring开发环境并编写第一个Spring小程序 2015-05-27 0个评论 来源:茕夜 收藏 我要投稿 一.前面,我写了一篇Spring框架的基础知识文章,里面没 ...
- 简要描述如何结合struts、hibernate、spring开发Web应用?
简要描述如何结合struts.hibernate.spring开发Web应用? 解答:Struts可以将jsp页面的表单关联起来,就是把JSP页面的表单数据封装成javaBean,这样的话,在acti ...
- 基于Spring开发的DUBBO服务接口测试
基于Spring开发的DUBBO服务接口测试 知识共享主要内容: 1. Dubbo相关概念和架构,以及dubbo服务程序开发步骤. 2. 基于Spring开发框架的dubbo服务接口测试相关配置. 3 ...
- 学习spring2--跟我一起学Spring 3(3)–使用Spring开发第一个HelloWorld应用
http://www.importnew.com/13246.html 首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 我要投稿 更多频道 » - 导航条 - 首页 所有文章 资讯 ...
随机推荐
- HDU 4549
水题: 费马小定理+快速幂+矩阵快速幂 (第一次用到费马小定理) #include<bits/stdc++.h> using namespace std; typedef long lon ...
- 如何在Mac 终端上Git 项目的一次常规操作
首先,Git的工作流是怎样的? 你的本地仓库由 git 维护的三棵“树”组成. 第一个是你的 工作目录,它持有实际文件: 第二个是 暂存区(Index),它像个缓存区域,临时保存你的改动: 最后是 H ...
- Django 中间件 请求前
中间件: class TestMiddleware(object): """中间件类""" def __init__(self): &quo ...
- bootstrap DataTable绑定数据带服务器分页
<!-- DataTables --> 这两个文件在我的文件夹里面<script src="~/bower_components/datatables.net/js/jq ...
- Solidity基础
方法和匿名方法: funcion name(<parameter types>){public|private|internal|external}[constant][payable][ ...
- iOS 10 申请隐私权限的一些常用选项
Privacy - Photo Library Usage Description 访问相册 Privacy - Camera Usag ...
- Confluence 6 启用和禁用 Office 连接器
如果你希望限制访问 Office 连接器的所有组件或者部分组件,你可以禁用整个插件也可以禁用插件中的某个模块. 希望启用或禁用 Office 连接器模块: 进入 > 基本配置(General ...
- LeetCode(90):子集 II
Medium! 题目描述: 给定一个可能包含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 说明:解集不能包含重复的子集. 示例: 输入: [1,2,2] 输出: [ [2], [1 ...
- 《剑指offer》 跳台阶
本题来自<剑指offer> 跳台阶 题目1: 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果). 思路: 同上一篇. C ...
- Java 获取图片的大小、宽、高
参考:https://www.cnblogs.com/hongten/archive/2012/11/26/hongten_java_ImageReader_BufferedImage.html im ...