<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>依赖注入 on 知识铺的博客</title>
    <link>https://index.zshipu.com/geek/tags/%E4%BE%9D%E8%B5%96%E6%B3%A8%E5%85%A5/</link>
    <description>Recent content in 依赖注入 on 知识铺的博客</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-CN</language>
    <lastBuildDate>Wed, 02 Sep 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://index.zshipu.com/geek/tags/%E4%BE%9D%E8%B5%96%E6%B3%A8%E5%85%A5/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>一次空指针异常暴露的 Spring Bean 生命周期陷阱</title>
      <link>https://index.zshipu.com/geek/post/20260902/%E4%B8%80%E6%AC%A1%E7%A9%BA%E6%8C%87%E9%92%88%E5%BC%82%E5%B8%B8%E6%9A%B4%E9%9C%B2%E7%9A%84-Spring-Bean-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%99%B7%E9%98%B1/</link>
      <pubDate>Wed, 02 Sep 2026 00:00:00 +0000</pubDate>
      <guid>https://index.zshipu.com/geek/post/20260902/%E4%B8%80%E6%AC%A1%E7%A9%BA%E6%8C%87%E9%92%88%E5%BC%82%E5%B8%B8%E6%9A%B4%E9%9C%B2%E7%9A%84-Spring-Bean-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%99%B7%E9%98%B1/</guid>
      <description>一个 Spring 服务的空指针异常，根源指向了 Bean 初始化顺序而非业务代码。排查发现 @Autowired 字段在 @PostConstruct 方法中仍为 null，异常堆栈最终指向容器启动时的依赖加载时序。这次 NPE 直接暴露了默认生命周期的隐藏陷阱。 NPE 案例中依赖注入尚未完成的真实场景 实际案例中，一个服务类标注了 @Service，里面有一个 @Autowired 的依赖 B</description>
    </item>
  </channel>
</rss>
