Tagged articles
3 articles
Page 1 of 1
Java Captain
Java Captain
Jul 4, 2025 · Backend Development

Why Getting Spring Beans in Non‑Spring Classes Causes NullPointerExceptions

This article explains why retrieving Spring beans from classes not managed by Spring can cause NullPointerExceptions and failed autowiring, demonstrates two code examples—using a utility class and @Autowired in a plain class—and recommends registering such classes as Spring components to ensure proper dependency management.

Bean RetrievalSpring Bootdependency-injection
0 likes · 5 min read
Why Getting Spring Beans in Non‑Spring Classes Causes NullPointerExceptions
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Jun 24, 2025 · Backend Development

12 Powerful Ways to Retrieve Beans in Spring Boot 3 – A Practical Guide

This article presents twelve practical techniques for obtaining Spring beans—including @Autowired, @Resource, @Inject, constructor injection, ApplicationContext, BeanFactory, ObjectProvider, @Lookup, BeanFactoryUtils, BeanFactoryAnnotationUtils, custom utilities, and @Value with SpEL—complete with code examples and usage scenarios to help developers choose the most suitable approach.

Bean RetrievalCode ExamplesSpring Boot
0 likes · 11 min read
12 Powerful Ways to Retrieve Beans in Spring Boot 3 – A Practical Guide
Top Architect
Top Architect
Oct 29, 2021 · Backend Development

Three Methods to Obtain Spring Beans in Static Context: @PostConstruct, ApplicationContext, and ApplicationContextAware

This article explains three practical ways to retrieve Spring beans from static methods—using @PostConstruct annotation, a static ApplicationContext defined in the main class, and a manually injected ApplicationContext via ApplicationContextAware—complete with code examples and usage notes.

Bean RetrievalPostConstructSpring Boot
0 likes · 5 min read
Three Methods to Obtain Spring Beans in Static Context: @PostConstruct, ApplicationContext, and ApplicationContextAware