常用的spring 配置文件备忘

SPRING 2.5 + STRUTS2 配置文件 注释备忘 最近接受了一个项目,SPRING 2.5 + STRUTS2 的。之前的项目只有接触过SPRING 1.X 和 STRUTS 1.X 的。 还是先熟悉一下配置文件的好。 SPRING 2.5 的配置果然比 SPRING 1.X / SPRING 2.0 简洁多了。 第一部分:WEB.XML<web-app version="2.4" xmlns="http:// 阅读详情


ApplicationContext
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
  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://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

  <dubbo:annotation />
  <context:component-scan base-package="com.flyingtiger"/>
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>classpath:config/*.properties</value>
      </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
  </bean>
  <bean class="com.flyingtiger.quote.provider.util.PackageMessageUtil"/>
  <import resource="redis.xml"/>
  <import resource="rabbit.xml"/>
  <import resource="mybatis.xml"/>
  <import resource="mvc.xml"/>
  <import resource="quartz.xml"/>
  <import resource="dubbo.xml"/>

</beans>

spring-mybatis

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.springframework.org/schema/beans"
  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/tx
       http://www.springframework.org/schema/tx/spring-tx.xsd">

  <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
  </bean>

  <tx:annotation-driven transaction-manager="transactionManager"/>

  <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${mysql.driver}"/>
    <property name="url" value="${mysql.url}"/>
    <property name="username" value="${mysql.username}"/>
    <property name="password" value="${mysql.password}"/>
    <property name="initialSize" value="${mysql.initialSize}"/>
    <property name="maxActive" value="${mysql.maxActive}"/>
    <property name="minIdle" value="${mysql.minIdle}"/>
    <property name="maxWait" value="60000"/>
    <property name="validationQuery" value="SELECT 1"/>
    <property name="testOnBorrow" value="false"/>
    <property name="testOnReturn" value="false"/>
    <property name="testWhileIdle" value="true"/>
    <property name="timeBetweenEvictionRunsMillis" value="60000"/>
    <property name="minEvictableIdleTimeMillis" value="25200000"/>
    <property name="removeAbandoned" value="true"/>
    <property name="removeAbandonedTimeout" value="1800"/>
    <property name="logAbandoned" value="true"/>
  </bean>

  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>
  </bean>

  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.flyingtiger.quote.provider.dao"/>
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
  </bean>
</beans>

spring-quartz

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.springframework.org/schema/beans"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       ">
  <bean id="exchangeService" scope="singleton"
    class="com.flyingtiger.quote.provider.http.service.ExchangeService"/>
  <bean id="contractService" scope="singleton"
    class="com.flyingtiger.quote.provider.service.ContractService"/>
  <!-- JOBS -->
  <bean id="reloadExchangeJob"
    class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="exchangeService"/>
    <property name="targetMethod" value="loadExchange"/>
  </bean>

  <!-- TRIGGERS -->
  <bean id="reloadExchangeTrigger"
    class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="reloadExchangeJob"/>
    <property name="cronExpression" value="0 */1 * * * ?"/>
  </bean>
  <!-- scheduler -->
  <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
      <list>
        <ref bean="reloadExchangeTrigger"/>
      </list>
    </property>
    <property name="waitForJobsToCompleteOnShutdown" value="true" />
  </bean>

</beans>

spring-rabbit
<?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:rabbit="http://www.springframework.org/schema/rabbit"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">

  <bean id="rabbitConnectionFactory"
    class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
    <property name="addresses" value="${rabbitmq.addresses}"/>
    <property name="username" value="${rabbitmq.username}"/>
    <property name="password" value="${rabbitmq.password}"/>
    <property name="connectionThreadFactory" ref="trim"/>
    <property name="channelCacheSize" value="${rabbitmq.channelCacheSize}"/>
    <property name="connectionLimit" value="${rabbitmq.connectionLimit}"/>
    <property name="channelCheckoutTimeout" value="${rabbitmq.channelCheckoutTimeout}"/>
  </bean>

  <bean id="trim" class="org.springframework.scheduling.concurrent.CustomizableThreadFactory">
    <constructor-arg value="rabbitmq-"/>
  </bean>

  <rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory"/>

  <rabbit:admin connection-factory="rabbitConnectionFactory"/>
  <rabbit:queue id="queueMarketPrice" durable="true" auto-delete="false" exclusive="false"
    name="marketPrice"/>
  <rabbit:queue id="queueDealHistory" durable="true" auto-delete="false" exclusive="false"
    name="dealHistory"/>
  <rabbit:queue id="queueTrendItem" durable="true" auto-delete="false" exclusive="false"
    name="trendItem"/>
  <rabbit:queue id="queueMinKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="minKdataItem"/>
  <rabbit:queue id="queueFiveMinKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="fiveMinKdataItem"/>
  <rabbit:queue id="queueQuarterHourKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="quarterHourKdataItem"/>
  <rabbit:queue id="queueHalfHourKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="halfHourKdataItem"/>
  <rabbit:queue id="queueHourKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="hourKdataItem"/>
  <rabbit:queue id="queueDayKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="dayKdataItem"/>
  <rabbit:queue id="queueWeekKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="weekKdataItem"/>
  <rabbit:queue id="queueMonthKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="monthKdataItem"/>
  <rabbit:queue id="queueYearKdataItem" durable="true" auto-delete="false" exclusive="false"
    name="yearKdataItem"/>


  <bean id="marketPriceListener"
    class="com.flyingtiger.quote.provider.listener.MarketValueListener"/>
  <bean id="historyDealListener"
    class="com.flyingtiger.quote.provider.listener.HistoryDealValueListener"/>
  <bean id="trendDetailListener"
    class="com.flyingtiger.quote.provider.listener.TrendDetailListener"/>
  <bean id="minKDataListener" class="com.flyingtiger.quote.provider.listener.MinKDataListener"/>
  <bean id="fiveMinKDataListener"
    class="com.flyingtiger.quote.provider.listener.FiveMinKDataListener"/>
  <bean id="quarterHourKDataListener"
    class="com.flyingtiger.quote.provider.listener.QuarterHourKDataListener"/>
  <bean id="hourKDataListener" class="com.flyingtiger.quote.provider.listener.HourKDataListener"/>
  <bean id="halfHourKDataListener"
    class="com.flyingtiger.quote.provider.listener.HalfHourKDataListener"/>
  <bean id="dayKDataListener" class="com.flyingtiger.quote.provider.listener.DayKDataListener"/>
  <bean id="monthKDataListener" class="com.flyingtiger.quote.provider.listener.MonthKDataListener"/>
  <bean id="weekKDataListener" class="com.flyingtiger.quote.provider.listener.WeekKDataListener"/>
  <bean id="yearKDataListener" class="com.flyingtiger.quote.provider.listener.YearKDataListener"/>

  <rabbit:direct-exchange id="exchangeQuoteTrim" name="quoteTrim" durable="true"
    auto-delete="false">
    <rabbit:bindings>
      <rabbit:binding queue="queueMarketPrice" key="marketPrice"/>
      <rabbit:binding queue="queueTrendItem" key="trendItem"/>
      <rabbit:binding queue="queueDealHistory" key="dealHistory"/>
      <rabbit:binding queue="queueMinKdataItem" key="minKdataItem"/>
      <rabbit:binding queue="queueFiveMinKdataItem" key="fiveMinKdataItem"/>
      <rabbit:binding queue="queueQuarterHourKdataItem" key="quarterHourKdataItem"/>
      <rabbit:binding queue="queueHalfHourKdataItem" key="halfHourKdataItem"/>
      <rabbit:binding queue="queueHourKdataItem" key="quarterHourKdataItem"/>
      <rabbit:binding queue="queueDayKdataItem" key="dayKdataItem"/>
      <rabbit:binding queue="queueWeekKdataItem" key="weekKdataItem"/>
      <rabbit:binding queue="queueMonthKdataItem" key="monthKdataItem"/>
      <rabbit:binding queue="queueYearKdataItem" key="yearKdataItem"/>
    </rabbit:bindings>
  </rabbit:direct-exchange>

  <rabbit:listener-container connection-factory="rabbitConnectionFactory">
    <rabbit:listener ref="marketPriceListener" queues="queueMarketPrice"/>
    <rabbit:listener ref="historyDealListener" queues="queueDealHistory"/>
    <rabbit:listener ref="trendDetailListener" queues="queueTrendItem"/>
    <rabbit:listener ref="minKDataListener" queues="queueMinKdataItem"/>
    <rabbit:listener ref="fiveMinKDataListener" queues="queueFiveMinKdataItem"/>
    <rabbit:listener ref="quarterHourKDataListener" queues="queueQuarterHourKdataItem"/>
    <rabbit:listener ref="halfHourKDataListener" queues="queueHalfHourKdataItem"/>
    <rabbit:listener ref="hourKDataListener" queues="queueHourKdataItem"/>
    <rabbit:listener ref="dayKDataListener" queues="queueDayKdataItem"/>
    <rabbit:listener ref="weekKDataListener" queues="queueWeekKdataItem"/>
    <rabbit:listener ref="monthKDataListener" queues="queueMonthKdataItem"/>
    <rabbit:listener ref="yearKDataListener" queues="queueYearKdataItem"/>
  </rabbit:listener-container>
</beans>

spring-redis

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.springframework.org/schema/beans"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
    <property name="maxIdle" value="${redis.pool.maxIdle}"/>
    <property name="minIdle" value="${redis.pool.minIdle}"/>
    <property name="testOnBorrow" value="${redis.pool.testOnBorrow}"/>
    <property name="testOnReturn" value="${redis.pool.testOnReturn}"/>
  </bean>

  <bean id="connectionFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <property name="poolConfig" ref="jedisPoolConfig"/>
    <property name="port" value="${redis.port}"/>
    <property name="hostName" value="${redis.host}"/>
    <property name="password" value="${redis.password}"/>
    <property name="database" value="${redis.database}"/>
  </bean>


  <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="keySerializer">
      <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
    </property>
    <property name="valueSerializer">
      <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
    </property>
    <property name="hashKeySerializer">
      <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
    </property>
    <property name="hashValueSerializer">
      <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
    </property>
  </bean>


  <bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
  </bean>

  <bean id="redisHelper" class="com.zebrafutures.commons.redis.RedisHelper">
    <property name="redisTemplate" ref="redisTemplate"/>
    <property name="stringRedisTemplate" ref="stringRedisTemplate"/>
  </bean>
</beans>






spring mvc注入配置文件里的属性 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> classpath:config.properties classpath:db.properties 到spring的主配置文件中,可是程序里面还是读去不到,读 阅读详情

相关推荐

wifi/BT芯片RTL8723DS驱动移植和测试之一wifi篇

本文主要介绍如何在stm32mp157中移植并测试芯片RTL8723DS的wifi功能。

汉尼拔勇闯天涯 8741

【配置详解】Quartz配置文件详解

 我们通常是通过quartz.properties属性配置文件(默认情况下均使用该文件)结合StdSchedulerFactory 来使用Quartz的。StdSchedulerFactory 会加载属性配置文件并实例化一个Scheduler。   默认情况下,Quartz会加载classpath下的”quartz.properties”文件作为配置属性,如果找不到则会使用quartz框架自己...

weixin_33861800的博客 6880

Qt5+OSG实战:如何用osgQOpenGLWidget在窗口中加载3D模型(附完整代码)

本文详细解析了如何在Qt5中使用osgQOpenGLWidget加载和渲染3D模型,涵盖环境配置、核心架构、性能优化及高级技巧。通过实战案例和完整代码,帮助开发者实现工业级3D模型渲染,提升Qt与OSG的整合效率。

weixin_42741930的博客 263

spring quartz配置使用

spring quartz配置使用 前期项目使用spring task配置的,由于执行是单线程方式,一个定时任务执行太久会影响下一个定时任务执行,所以改用spring quartz 多个线程并发的方式 1.task封装类 public class TaskConfig { private String jobName; private String jobGroup; private String triggerName; private String trigger

qq_41813060的博客 456

Blender入门教程-3D视图界面介绍

3D视图用于与3D场景交互,可用于各种目的,例如建模、动画、纹理绘制等。在关闭 启动画面 后,启动场景会显示在3D视口中(如果没有加载其他blend文件)。01 标题栏标题栏包含了基于当前 模式 的各种菜单和控制。

weixin_52345129的博客 2287

Labview及NI-USRP驱动安装教程

软件下载 安装使用的LabVIEW2018及NI-USRP驱动程序已上传,下载地址: 天翼云盘链接 (访问码:oc33) 百度网盘链接 (提取码:88mi) (注:天翼云盘下载不限速) LabVIEW2018安装步骤 右键软件压缩包选择解压至LabVIEW2018 选中文件,鼠标右击选择以管理员身份打开2018LV-WinChn.exe文件。 点击确定。 点击Unzip解压。 点击确定。 点击下一步。 填写任意信息后,点击下一步。 点击下一步。 点击浏览更改安装路径建议安装到除C盘以

dadapongi6的博客 2万+

关于spring核心配置文件中的各项主要配置

1:spring的核心配置文件中的各种配置。      spring的核心配置文件的名字 叫做 applicationContext.xml,后期也可以通过配置文件中的配置修改名称,在web.xml中进行如下配置:   [html] view plain copy &lt;context-param&gt;         &lt;param-name&gt;contextConfigLocati...

time_2018的博客 835

如何解决Dify重新部署(升级到最新版)后出现的Setup failed: PermissionDenied等问题

重新部署(升级)Dify后遇到Permission denied错误?🚫 本文详细分析了这个问题的原因🔐,并提供了完整的解决步骤来修复这个问题✨

XiaoqiangClub的博客 1653

Redis使用实例(RedisHelper)

public class RedisHelper { private static JedisPool pool = null; static { if (pool == null) { JedisPoolConfig config = new JedisPoolConfig(); // 控制一个pool可分配多少个jedis实例,通过

limuzi13的专栏 9403

[QMT和ptrade量化交易小白入门]-109、小市值选股的基础上用六脉神剑评分,回测年化可到132%

本专栏主要是介绍QMT和ptrade的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写200篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步。

木头大左的博客 1861

JavaScript实现量化交易策略(附完整源码)

JavaScript实现量化交易策略(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 721

Spring quartz的配置

Spring quartz的配置: 表达式意义 “0 0 12 * * ?” 每天中午12点触发 “0 15 10 ? * *” 每天上午10:15触发 “0 15 10 * * ?” 每天上午10:15触发 “0 15 10 * * ? *” 每天上午10:15触发 “0 15 10 * * ? 2005” 2005年的每天上午10:15触发 “0 * 14 * * ?” 在每天下午2点到下午2:59期间的每1分钟触发 “0 0/5 14 * * ?” 在每天下午2点到下午2:55期间的每5分钟触发 “0

weixin_42270584的博客 310

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

spring学习备忘录

xml文件是否是activeProfile的设置 <?xml version="1.0" encoding="UTF-8"?> <beans profile="dev" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springf

top_explore的博客 918

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Spring 3.1配置文件示例(备忘)

<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:cache="http://www.springfr

KimSoft's Blog 1万+

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

学习Spring AOP编程的一些备忘录

项目需求,补充学习了Spring AOP,练习了小项目,出现的问题记录备忘一下。

u014696787的博客 386

关于Spring配置文件的动态载入的修改

此文章转载自http://www.blogjava.net/bigbigtooth/archive/2008/03/27/85756.html 用于备忘学习 一、 概述 Spring MVC 的开发是基于 action-servlet.xml 进行配置,但不支持开发模式下进行动态的配置文件载入。本文主要是介绍如何修改 Spring 的源代码,使 Sprin...

易米-自由-科技 433

Spring Boot 使用备忘

spring boot 日常使用备忘 + Spring Boot 指定运行配置文件 + Spring boot 排除自动配置

大鱼的博客 291

Spring读取二种绝对与类路径的配置文件备忘

http://www.cnblogs.com/highriver/archive/2012/03/29/2423984.html spring中读取绝对路径与类路径的二种方式:              /WEB-INF/mail.properties       classpath: conf/sqlmap/jdbc.properties

Mr__fang的专栏 2531

spring基础功能实战备忘录

spring基础功能spring工厂 spring工厂 1 配置xml文件 <!--静态工厂配置--> <bean id="apple1" class="com.springdemo.stu.AppleStaticFactory" factory-method="getInstance"> <constructor-arg value="red"></constructor-arg> </bean>

小浪与艳花 344

spring配置文件(备忘录)

1.基本配置:&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.spring

Javy的专栏 177

Spring注释备忘单

  Spring对于每个Java程序员的重要性都是不言而喻的,所以Spring注释也同样重要,这里收集了开发人员使用的一些有用注释,建议收藏。   重要的Spring注释   以下是任何使用Spring的Java开发人员都应该知道的最重要的注释:   @Configuration——用于将类标记为bean定义的源。bean是要连接在一起的系统组件。用@Bean注释标记的方法是Bean生产者。Spring将为您处理bean的生命周期,它将使用这些方法来创建bean。   @ComponentScan—

yueqian_edu的博客 427

spring4.2 MVC注解备忘

以下为备忘。 1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.

卧龙居 1321

spring中quartz配置文件

1.下面是spring中的quartz配置文件的备份,以备参考 uploadFile 0,30 * * * * ? 2.qua...

learnmore的实验田 187

Spring由于web配置导致的spring配置文件找不到的问题的解决方案

Spring由于web配置导致的spring配置文件找不到的问题的解决方案

dearbaba_11的博客 327
上一篇: spring集成quartz的内存泄漏问题总结
下一篇: 代码生成k线数据
韩慕灵
博客等级 码龄15年 8粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值