<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Spring on Shellj的博客</title>
    <link>https://im.shellj.com/tags/spring/</link>
    <description>Recent content in Spring on Shellj的博客</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 22 Dec 2023 01:58:35 +0800</lastBuildDate>
    <atom:link href="https://im.shellj.com/tags/spring/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>一个 Bug 给公司带来20000多损失</title>
      <link>https://im.shellj.com/posts/2022/11/a-20000-bug/</link>
      <pubDate>Wed, 23 Nov 2022 22:08:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2022/11/a-20000-bug/</guid>
      <description>&lt;p&gt;最近连续两个月代码出问题，给公司带来了损失，第一次是2000多，第二次直接20000多，这里来做一次总结。&lt;/p&gt;&#xA;&lt;h2 id=&#34;问题&#34;&gt;问题&lt;/h2&gt;&#xA;&lt;p&gt;咱们的发布流程是 测试-&amp;gt;预发-&amp;gt;生产，这样子三个环境，代码到生产环境的时候会检查是否到预发环境。出问题的是Spring的一个定时任务，改了一个和钱有关的比例后按照流程发布上线，过了几天发现有些金额不对，排查后发现多了一个环境[预发2]，这个环境和生产环境是共用数据库的，这个环境是为了一些需要生产数据的测试，但是这个当时没人维护了，导致代码落后生产，定时任务执行了原来的逻辑。&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring Scheduled 三种定时方式</title>
      <link>https://im.shellj.com/posts/2022/11/spring-scheduled/</link>
      <pubDate>Mon, 14 Nov 2022 22:09:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2022/11/spring-scheduled/</guid>
      <description>&lt;p&gt;前面出了&lt;a href=&#34;https://im.shellj.com/2022/11/a-20000-bug.html&#34;&gt;一个20000+元的 Bug&lt;/a&gt;，现在来认真的看看 Spring Schedule 是如何处理定时任务的。&lt;/p&gt;&#xA;&lt;h2 id=&#34;spring-schedule-配置时间的三种方式&#34;&gt;Spring Schedule 配置时间的三种方式&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;fixRate: 间隔时间，会根据首次执行时间预先安排固定的时间，错过立即执行&lt;/li&gt;&#xA;&lt;li&gt;fixDelay: 间隔时间，上次结束时间后多少间隔后执行&lt;/li&gt;&#xA;&lt;li&gt;cron: 指定具体时间，错过立即执行&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;fixrate-运行方式&#34;&gt;fixRate 运行方式&lt;/h2&gt;&#xA;&lt;p&gt;fixRate 是会根据开始时间预先安排一系列的固定时间点，如果错过了安排的时间点，则立即执行，否则等待下一个执行时间点，如下图 fixRate=5000，每5秒执行一次，第二次执行超过了预先安排的点，导致第三次错过，则第三次立即执行，二第四次则在正常安排的时间点执行，值得注意的是第三次与第四次相隔仅一秒。&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring Data Jpa 多数据源选择无效</title>
      <link>https://im.shellj.com/posts/2021/06/spring-data-jpa-muti-datasource/</link>
      <pubDate>Fri, 25 Jun 2021 21:17:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2021/06/spring-data-jpa-muti-datasource/</guid>
      <description>&lt;p&gt;有个项目用的 &lt;a href=&#34;https://spring.io/projects/spring-data-jpa&#34;&gt;Spring Data Jpa&lt;/a&gt; ，里面需要多数据源来做分库，正常流程是拦截器拿出用户信息，然后把分库信息设置到 ThreadLocal 里，后面使用就没问题了。但最近遇到个问题，在 Service 层重新分库信息居然没用，依然会使用首次获取到的数据库连接。&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring Cloud Stream 初尝</title>
      <link>https://im.shellj.com/posts/2018/07/spring-cloud-stream/</link>
      <pubDate>Mon, 02 Jul 2018 21:08:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2018/07/spring-cloud-stream/</guid>
      <description>&lt;p&gt;公司里目前用的是RocketMQ，用的过程中遇到一些问题，逐渐将一些业务转到 &lt;a href=&#34;https://kafka.apache.org/&#34;&gt;kafka&lt;/a&gt; 上，正好目前项目是spring boot项目，所以就来试试 spring cloud stream，本地环境有 rabbitmq，所以使用它了。&lt;/p&gt;</description>
    </item>
    <item>
      <title>spring transaction不生效的一些原因</title>
      <link>https://im.shellj.com/posts/2017/05/spring-transaction/</link>
      <pubDate>Mon, 15 May 2017 14:57:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2017/05/spring-transaction/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://i.loli.net/2018/06/30/5b3704afebe2d.jpg&#34; alt=&#34;DSC_3900&#34;&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;同一个类中一个方法调用的另一个有事务的方法&#34;&gt;同一个类中一个方法调用的另一个有事务的方法&lt;/h3&gt;&#xA;&lt;p&gt;在spring的声明式注解中，如果直接调用的方法不包含&lt;code&gt;Transactional&lt;/code&gt;注解，那么即使这个方法里面调用的其他方法包含注解，那么事务也是不会生效的，例如下面的这段代码：&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mybatis example</title>
      <link>https://im.shellj.com/posts/2017/02/mybatis-example/</link>
      <pubDate>Wed, 15 Feb 2017 13:32:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2017/02/mybatis-example/</guid>
      <description>&lt;p&gt;这篇文章主要是一个基本的例子，分为两个部分，&lt;code&gt;mybatis独立的配置&lt;/code&gt;和&lt;code&gt;mybatis-spring配置&lt;/code&gt;&lt;br&gt;&#xA;项目的最终地址在这里：&lt;a href=&#34;https://github.com/shellj/mybatis-example&#34;&gt;https://github.com/shellj/mybatis-example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;mybatis单独的配置&#34;&gt;Mybatis单独的配置&lt;/h2&gt;&#xA;&lt;p&gt;根据官方的例子进行配置&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
