Blog Articles
-
为什么我的定时器不跑了
<p>最近要搞个小服务运行在多家客户的windows服务器上,里面有两个定时任务,一个是定时检查版本号,一个是定时向服务器汇报状态,都使用 spring 的@Scheduled实现。<br /> 昨天晚上让它们跑着,今天上午一看,居然没有汇报状态了,(无奈,肯定有bug)。</p> <p>登录服务器,看到服务还在运行,看了一下没有打日志了,访问端口有数据返回,那这个服务应该还活着,定时器不跑了?<br /> 没有太多的办法,老实下载了一个jdk安装, jstack看一下,发现定时任务线程被阻塞了,而且居然是
Published on: -
spring boot 集成 redis 缓存
<p>在spring中使用redis缓存有三种方式:</p> <ul> <li>直接使用各种redis客户端提供的接口</li> <li>使用spring data redis</li> <li>使用spring caching 注解</li> </ul> <h1><a id="_5"></a>直接使用客户端提供的接口</h1> <p>这个没什么好说的, 直接看相应客户端的文档就行了, 当前redis有非常多的客户端<br /> 官网的客户端列表: https://redis.io/clients<br /
Published on: -
使用Redisson操作分布式队列对象比较问题
<p>先说结论:<br /> 使用Redisson提供的RedissonPriorityQueue时, 比较操作不使用对象的equals, 而是使用compare比较.</p> <p>最近做一个定时任务的服务, 需要用到分布式优先级队列, 选择了Redisson库.<br /> Redisson的队列有很多, 也都继承了java包的Queue接口, 看起来非常方便.<br /> 修改代码后, 发现一个很奇怪的问题, 将一个元素加进去之后, 移除不了, remove 返回了false.<br /> 元素是一
Published on: -
Spring 注解缓存总结
<p>文档:<a href="https://docs.spring.io/spring/docs/5.1.9.RELEASE/spring-framework-reference/integration.html#cache" target="_blank">https://docs.spring.io/spring/docs/5.1.9.RELEASE/spring-framework-reference/integration.html#cache</a><br /> Spring为我们提供了一组缓存
Published on: -
Spring 日志库搭配
<p>是不是经常被各种日志库搞得头晕脑转? 看看官方提供的日志库搭配吧。</p> <h1><a id="log4j__2"></a>log4j 搭配</h1> <p><a href="http://logging.apache.org/log4j/2.x/runtime-dependencies.html" target="_blank">http://logging.apache.org/log4j/2.x/runtime-dependencies.html</a></p> <table> <thead>
Published on: -
spring boot log4j2
<p>记录一下spring boot使用log4j2日志框架, 配置使用异步写入日志</p> <h3><a id="gradle_1"></a>导入依赖(gradle)</h3> <pre><div class="hljs"><code class="lang-java">configurations { all*.exclude group: <span class="hljs-string">'org.slf4j'</span>, <span class="hljs-keyword">modul
Published on: -
Unmarshaller转换xml到对像为空的问题
最近使用到@ResponseBody解析xml,但是始终数据为空,开始以为是HttpMessageConverter没有配置好,然后自己定义了一个配置,debug进去,发现问题出在unmarshal这里,源数据是对的,结果为空。实验后发现,被转换的类,成员必须定义为public或者使用@XmlElement注释,否则转换不出来,即使名字一样。 也就是说下面这个类不能转换出来: @XmlRoo
Published on: -
sql事务
事务概念 事务特性ACID 事务隔离级别 序列化Serializable 可重复读Repeatable read 读已提交Read committed 读未提交Read uncommitted 事务隔离级别读问题 事务的默认隔离级别 案例分析 参考资料 事务概念 A transaction symbolizes a unit of work performed within a database
Published on: -
[spring-boot] 集成shiro (二)
session shiro有自己的session管理类,因为之前已经在项目中集成了spring session,shiro也可以使用spring session,只要配置shiro使用容器的session管理即可,spring session在后面拦截了容器的session实现。 @Bean(name = "securityManager") public SecurityMa
Published on: -
[spring-boot] 集成shiro
shiro介绍 shiro是一个权限管理框架,基于用户-角色-权限。一个用户可以有多个角色,一个角色有多个权限,每个权限指定了资源的访问。 shiro的原理是在所有请求之前设置一个filter,这个filter判断哪些资源需要权限,哪些不要,对于不需要权限的直接放行,对于需要权限的,使用securityManager和realm进行身份验证和授权,如果验证失败或者权限不足,都跳转到登录页面或者...
Published on: