Spring
共 7 篇文章
Spring事件驱动模型
事件驱动模型简介 事件驱动模型也就是我们常说的观察者,或者发布-订阅模型;理解它的几个关键点: 首先是一种对象间的一对多的关系;最简单的如交通信号灯,信号灯是目标(一方),行人注视着信号灯(多方); 当目标发送改变(发布),观察者(订阅者)就可以接收到改变; 观察者如何处理(如行人如何走,是快走/慢走/不走,目标不会管的),目标无需干涉;所以就松散耦合了它们之间的关系。 接下来先看一个用户注册的例子: 用户注册成功后,需要做这么多事: 1、加积分 2、发确认邮件 3、如果是游戏帐户,可能赠送游戏大礼包 4、索引用户数据 ………… 问题: UserService和其他Service耦合严重,增…
2014-12-29 09:34 · Spring · Spring
HOW-TO: Get started quickly with Spring 4.0 to build a simple REST-Like API (wal
HOW-TO: Get started quickly with Spring 4.0 to build a simple REST-Like API (walkthrough) Yet another tutorial about creating Web API with Spring MVC. Not really sophisticated. Just a walkthrough. The resulting app will serve simple API, will use Mongo as its persistence and it will be secured with…
2014-05-09 20:29 · Spring · Spring
利用maven创建spring-osgi powered 多bundle工程
1、创建总控pom文件添加如下内容 <?xml version="1.0" encoding="UTF-8"?> <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.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <name…
spring cron表达式
Cron表达式是一个字符串,字符串以5或6个空格隔开,分开工6或7个域,每一个域代表一个含义,Cron有如下两种语法 格式: Seconds Minutes Hours DayofMonth Month DayofWeek Year 或 Seconds Minutes Hours DayofMonth Month DayofWeek 每一个域可出现的字符如下: 代码 Seconds:可出现,- * / 四个字符,有效范围为0-59的整数 Minutes:可出现,- * / 四个字符,有效范围为0-59的整数 Hours:可出现,- * / 四个字符,有效范围为0-23的整数 DayofMon…
2014-01-26 10:55 · Spring · cron · quartz · quartz · Spring · Cron
RabbitMQ 使用教程 与 spring整合
spring integration系列 之RabbitMQ and spring 文章中 很多人都不熟悉讲这个 大家云里雾里,我确实忽略了 这个问题,这一集 就是基础篇 基本的RabbitMQ 在实际工作中我们常常使用RabbitMQ发布以及监听消息 其实大多数时候 我用它来做大量的异步消息通讯 数据的临时存储 用途 下面第一步 添加相关依赖 1 <!-- Spring RabbitMQ --> 2 <dependency> 3 <groupId>org.springframework.amqp</groupId> 4 <artifactId>spring-rabbit</artifact…
Spring4新特性——注解、脚本、任务、MVC等其他特性改进
一、注解方面的改进 spring4对注解API和ApplicationContext获取注解Bean做了一点改进。 获取注解的注解,如@Service是被@Compent注解的注解,可以通过如下方式获取@Componet注解实例: Java代码 Annotation service = AnnotationUtils.findAnnotation(ABService.class, org.springframework.stereotype.Service.class); Annotation component = AnnotationUtils.getAnnotation(service…
2013-12-29 12:39 · Spring · Spring
spring建立虚拟db环境进行单测
在进行DAO本地测试或者单元测试时,db环境有时很难弄,而且即使调通了db环境,有时也不想往db里面灌些无用数据,所以,为了不对真实db环境造成侵入,spring提供了一套虚拟db环境,利用它可以方便地进行单元测试。 在spring环境中配置: <jdbc:embedded-database id="db_product_recommend" type ="H2"> <jdbc:script. location="classpath:database/product-recommend-schema.sql" /> <jdbc:script. location="classpath:data…