
Spring专题
Leon-Zheng
未来已来
展开
-
Spring 主要子项目
Spring 主要子项目(1)Spring Cloud Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circui原创 2017-03-13 00:51:07 · 1308 阅读 · 0 评论 -
Spring AOP报错 error at ::0 name binding only allowed in target, this, and args pcds
早上写了一个切面,定义大致如下:@Component@Aspectpublic class QuestionAspect { @AfterReturning(value = "execution(* com.xxx.service.SrviceImpl.create(vo)) && args(vo)") public void createQuestion(Questio原创 2017-11-28 12:14:51 · 3399 阅读 · 0 评论 -
Spring 使用小记
陆续记录一些平时使用spring遇到的问题1、Jpa findFistOrderByCreateTimeDesc 查不到数据 -> findFistByOrderByCreateTimeDesc2、RequestMapping指定输出的content-type -> @RequestMapping(value = "/v1/**", produces = "text/html;charse原创 2017-07-20 21:10:08 · 285 阅读 · 0 评论 -
Spring Data Jpa 异常:PropertyReferenceException: No property xx for type yy
今天在写完一个仓储层方法时,tomcat启动就抛出了一个异常,内容是:nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxRepository': Invocation of init method failed; nes原创 2017-10-13 19:57:01 · 5872 阅读 · 1 评论 -
SpringBoot 不显示Whitelabel Error Page
SpringBoot 不显示Whitelabel Error Page原创 2017-09-14 21:57:20 · 1449 阅读 · 0 评论 -
Spring JdbcTemplate query查询结果转换对象
在使用JdbcTemplate的时候,可以使用query方法来查询指定的sql语句,来返回我们需要的结果。query提供了RowMapper接口,可以方便的将查询结果转换为对象。RowMapper常见的有2个实现类BeanPropertyRowMapper和EntityRowMapper。在使用上,位置是等价的。//BeanPropertyRowMapperList list = jdb原创 2017-08-13 00:28:44 · 10089 阅读 · 1 评论 -
Spring RedisTemplate 批量获取值的2种方式
1、利用mGetList keys = new ArrayList<>();//初始keysList list = this.redisTemplate.opsForValue().multiGet(keys);2、利用PipeLinefinal List keys = new ArrayListList list = this.redisTemplate.executePipel原创 2017-08-09 14:54:05 · 42607 阅读 · 6 评论 -
Spring 方法覆盖工作原理
原创 2017-05-22 02:29:36 · 574 阅读 · 0 评论 -
面向切面编程(如Spring AOP)的一些基本概念
今天看下AOP相关的内容,有些概念是很早前看了,但是现在又有点忘记了,在这里在记录下,方便需要时回顾。其实最初看到AOP的时候,首先联想到的是装饰者模式,他也可以起到动态的增加功能,而又不影响原有的代码的效果。相比装饰模式一次只能对一个类做增强,AOP更加的灵活和强大,在符合条件任意的连接点(主要指方法,下面有定义),他可以统一定义增强操作的内容及发生的时间点(前、后、环绕、异常、返回)。AOP里原创 2017-04-27 02:00:25 · 640 阅读 · 0 评论 -
Spring中Converter和Formatter的异同点
Spring中Converter和Formatter,都是用来做数据转换的。他们都是在Spring 3.0才出现的。之前使用的数据处理类是PropertyEditor。可是PropertyEditor存在的问题是他不是线程安全的,同时他只能处理String到其他类型的转换。其实应用中需要转换的地方还蛮常见的,比如日期类型转成指定格式再输出等。先来来看下这两个接口都有哪些方法:Converter原创 2017-05-15 01:29:39 · 3245 阅读 · 0 评论 -
Spring JdbcTemplate批量更新速度很慢的问题
由于一次要执行很多条插入语句(5w条),通常通过mysql写原生的插入语句会有类似的格式:insert into TableAAA(f1,f2) values (f11v,f21v),(f12v,f22v)...执行速度上是没有问题,大概5,6秒。在用JdbcTemplate的时候,就是用batchUpdate方法来写批量执行的语句:String sql = "insert原创 2017-05-06 02:31:29 · 14904 阅读 · 6 评论 -
Spring PlaceHolder实现原理解析
在Spring中,使用properties/yml文件,可以很好的将各种配置项独立在文件中配置。Spring最终从配置文件中读取到的信息替换实际类中的属性值。本文阐述的就是这个过程Spring是如何实现的。这里简单的举个例子。bean.xml prop.propertiespassword=999999原创 2017-04-15 20:37:58 · 6552 阅读 · 0 评论 -
Spring 自定义标签
自定义标签,用来实现定义Bean的作用范围线程独立,每个线程产生自己的实例对象对象类public class Model {}标签处理类public class ThreadScopeHandler extends NamespaceHandlerSupport { public void init() { registerBe原创 2017-04-07 02:12:45 · 962 阅读 · 3 评论 -
Spring Cacheable注解不缓存null值
今天,用Cacheable注解时,发现空值,也会被缓存下来。下次另一个系统如果更新了值,这边从缓存取,还是空值,会有问题。所以一方面,希望另一个系统更新时,能清缓存,另一方面不希望缓存中有太多垃圾数据。参考http://stackoverflow.com/questions/12113725/how-do-i-tell-spring-cache-not-to-cache-null-value-原创 2017-03-20 13:44:13 · 30867 阅读 · 7 评论 -
Spring发展过程中的主要阶段
2002,Rod Johonson发表了>,包含了3万行的代码,在包com.interface21; 2003,Juerge Hoeller,Yann Caroff 联系Rod,将书中代码开源,Yann提出Spring这个词,冠于书中代码;并发布0.9,使用Apache 2.0协议;Thomas Risberg负责Spring JDBC;Ben Alex将Acegi Security原创 2017-03-13 01:17:34 · 1693 阅读 · 0 评论 -
Spring Jpa "No property xxx found for type xxx" 方法名被认为是属性
结论先行:在继承JpaRepository的接口中,其方法名不能与实现类有所差异,即使是包装类型的也不行。重现过程:1、定义接口public interface LatentUserRepository extends JpaRepository<LatentUser, Integer> { List<LatentStatusStat> statS...原创 2018-12-07 21:27:04 · 10214 阅读 · 0 评论