You can Autowire the ApplicationContext, either as a field
@Autowired
private ApplicationContext context;
or a method
@Autowired
public void context(ApplicationContext context) { this.context = context; }
Finally use
context.getBean(SomeClass.class)
More Related Contents:
- exclude @Component from @ComponentScan
- Spring Boot Configure and Use Two DataSources
- Filter invoke twice when register as Spring bean
- How can I log SQL statements in Spring Boot?
- Difference between @Mock, @MockBean and Mockito.mock()
- Spring Boot Adding Http Request Interceptors
- POSTing a @OneToMany sub-resource association in Spring Data REST
- Spring boot @ResponseBody doesn’t serialize entity id
- Spring Qualifier and property placeholder
- Can a spring boot @RestController be enabled/disabled using properties?
- Is it possible with Spring Boot to serve up JSPs with a JAR packaging?
- How to disable ‘X-Frame-Options’ response header in Spring Security?
- How to configure embedded Tomcat integrated with Spring to listen requests to IP address, besides localhost?
- Is spring default scope singleton or not?
- java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment
- How to enable HTTP response caching in Spring Boot
- Spring-Boot: How do I set JDBC pool properties like maximum number of connections?
- How to reinitialize a Spring Bean?
- Multiple WebSecurityConfigurerAdapter in spring boot for multiple patterns
- Heroku cannot deploy Java 11 Spring Boot App [duplicate]
- Using Spring 3 autowire in a standalone Java application
- Configuration using annotation @SpringBootApplication
- Autowiring in Spring bean (@Component) created with new keyword
- How to specify prefix for all controllers in Spring Boot?
- Spring Boot access static resources missing scr/main/resources
- bootstrap.yml configuration not processed anymore with Spring Cloud 2020.0
- How to use Spring Boot with MySQL database and JPA?
- How to modify request body before reaching controller in spring boot
- Spring Boot – Reading Text File using ResourceLoader
- How I create an error handler (404, 500…) in Spring Boot/MVC