Previous comments are ok, but I usually prefer:
@Autowired private ApplicationContext applicationContext;
More Related Contents:
- What is a NoSuchBeanDefinitionException and how do I fix it?
- Getting Spring Application Context
- Reload or refresh a Spring application context inside a test method?
- Xml configuration versus Annotation based configuration [closed]
- Singleton design pattern vs Singleton beans in Spring container
- How to enable request scope in async task executor
- Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful
- POST request via RestTemplate in JSON
- How to make spring inject value into a static field
- Spring Qualifier and property placeholder
- @Transactional method called from another method doesn’t obtain a transaction
- Is it possible with Spring Boot to serve up JSPs with a JAR packaging?
- Auto-wiring a List using util schema gives NoSuchBeanDefinitionException
- Is spring default scope singleton or not?
- java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment
- How to enable HTTP response caching in Spring Boot
- How to Autowire Bean of generic type in Spring?
- Java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
- spring scoped proxy bean
- How to get bean using application context in spring boot
- Maven Resource Filtering with Spring Boot: Could not resolve placeholder
- How to handle MaxUploadSizeExceededException
- Unable to use Spring Property Placeholders in logback.xml
- Where should I put @Transactional annotation: at an interface definition or at an implementing class?
- javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional
- What is meant by abstract=”true” in spring?
- Spring Data JPA: Query by Example?
- org.dbunit.dataset.NoSuchTableException: Did not find table ‘xxx’ in schema ‘null’
- Registering a SQL function with JPA and Hibernate
- Spring v3 no declaration can be found for element ‘mvc:resources’