登錄操作拋出 NPE,堆棧指向第 55 行(截圖不可見)。
Service Bean 未被 Spring 容器管理/注入失敗:
@Service / @Component 注解@Service 或 @Component@ComponentScan("com.example.service")@Autowired private UserService userService; (字段注入)Creating bean with name 'userService' 日志// 在 Controller 構造器/方法中打印
System.out.println("userService = " + userService); // null 即未注入
spring.main.allow-circular-references=false 禁止循環依賴@RequiredArgsConstructor (Lombok) 自動生成構造器NPE 現場第 55 行極大概率是 userService 調用處。Spring 注入失敗不報錯、運行時才 NPE,是新手最常踩的坑。