applicationContext备忘录

来源:互联网 发布:一句话木马 php 编辑:程序博客网 时间:2024/06/06 03:53

spring-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:util="http://www.springframework.org/schema/util"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:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="    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/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/context     http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 配置返回信息编码格式 --><mvc:annotation-driven><mvc:message-converters><bean class="org.springframework.http.converter.StringHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/plain; charset=UTF-8</value><value>text/json; charset=UTF-8</value><value>text/html; charset=UTF-8</value><value>application/json; charset=UTF-8</value></list></property></bean></mvc:message-converters></mvc:annotation-driven><!-- 加载静态资源 --><mvc:default-servlet-handler /><mvc:interceptors><mvc:interceptor><mvc:mapping path="/*/*" /><mvc:exclude-mapping path="/login/" /><mvc:exclude-mapping path="/login/login" /><mvc:exclude-mapping path="/cAppInterface/autoLogin" /><mvc:exclude-mapping path="/cAppInterface/login" /><bean class="com.nis.common.interceptor.ActionInterceptor"></bean></mvc:interceptor></mvc:interceptors><context:component-scan base-package="com.nis.controller"><!-- ,com.nis.common.frame.controller --> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>   <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> </context:component-scan><!-- Spring AOP自动扫描 --><aop:aspectj-autoproxy proxy-target-class="true"/><!-- 配置SpringMVC的视图解析器 --><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/view/" /><property name="suffix" value=".jsp" /><property name="order" value="1" /></bean><!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><property name="maxUploadSize"><value>-1</value></property><property name="defaultEncoding"><value>UTF-8</value></property></bean><!-- 数据分析定时下发工作类 -->     <!-- <bean id="MyFunction1" class="com.nis.common.MyFunction"/>    定义调用对象和调用对象的方法    <bean id="jobTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">        调用的类        <property name="targetObject">            <ref bean="MyFunction1"/>        </property>        调用类中的方法        <property name="targetMethod">            <value>work</value>                 </property>        <property name="concurrent" value="false"/>    </bean>    定义触发时间和触发的bean    <bean id="jobTaskTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">        <property name="jobDetail">            <ref bean="jobTask"/>        </property>        cron表达式 每2秒触发一次        <property name="cronExpression">            <value>*/2 * * * * ?</value>        </property>    </bean>       总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序    <bean id="taskManager" lazy-init="false" autowire="no"          class="org.springframework.scheduling.quartz.SchedulerFactoryBean">        <property name="triggers">            <list>                <ref bean="jobTaskTrigger"/>            </list>        </property>    </bean> --></beans>  

spring-mybatis.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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="    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/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd    http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 启用注解 -->    <context:annotation-config /><!-- 启动组件扫描,排除@Controller组件,该组件由SpringMVC配置文件扫描 -->    <context:component-scan base-package="com.nis">        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />    </context:component-scan><!-- 引入配置文件 --><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><!-- 多个locations, 单个location <value> --><property name="locations"><list><!-- <value>classpath*:mongodb.properties</value> --><value>classpath:db.properties</value></list></property><!-- 是否忽略不可解析的 --><property name="ignoreUnresolvablePlaceholders" value="true" /></bean><!-- 阿里 druid 数据库连接池 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"init-method="init" destroy-method="close"><!-- url,name,pwd --><property name="url" value="${db.url}" /><property name="username" value="${db.username}" /><property name="password" value="${db.password}" /><!-- 配置监控统计拦截的filters --><property name="filters" value="${db.filters}" /><!-- 最大并发连接数 --><property name="maxActive" value="${db.maxActive}" /><!-- 初始化连接数 --><property name="initialSize" value="${db.initialSize}"></property><!-- 获取连接最大等待超时时间 --><property name="maxWait" value="${db.maxWait}"></property><!-- 连接池最小空闲 --><property name="minIdle" value="${db.minIdle}"></property><!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --><property name="timeBetweenEvictionRunsMillis" value="${db.timeBetweenEvictionRunsMillis}" /><!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --><property name="minEvictableIdleTimeMillis" value="${db.minEvictableIdleTimeMillis}" /><!-- 用来检测连接是否有效的sql,要求是一个查询语句。 如果validationQuery为null,testOnBorrow、testOnReturn、 testWhileIdle都不会其作用 --><property name="validationQuery" value="SELECT 'x'" /><!-- 缺省 false 不影响性能 --><property name="testWhileIdle" value="true" /><!-- 缺省 false 影响性能 --><property name="testOnBorrow" value="false" /><!-- 缺省 false 影响性能 --><property name="testOnReturn" value="false" /><!-- 打开PSCache,并且指定每个连接上PSCache的大小 --><!-- mysql5.5以下没有PSCache功能,建议关闭掉 --><property name="poolPreparedStatements" value="true" /><property name="maxPoolPreparedStatementPerConnectionSize"value="20" /></bean><!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><!-- 自动扫描mapping.xml文件 --><property name="mapperLocations" value="classpath*:com/nis/**/*.xml"></property></bean><!-- DAO接口所在包名,Spring会自动查找其下的类  ,com.nis.common.frame.dao--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.nis.dao" /><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property></bean><!-- 事务管理 --><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><!-- tx标签自动注入  true对类进行代理,如果是false表示对接口进行代理--><tx:annotation-driven transaction-manager="transactionManager"/></beans>  


原创粉丝点击