Which Aware interfaces does Spring support?





Which Aware interfaces does Spring support?

  • ApplicationContextAware: Get the ApplicationContext object
  • BeanFactoryAware: Get the BeanFactory object
  • BeanNameAware: Get the name of the Bean
  • EnvironmentAware: Get the Environment object
  • ResourceLoaderAware: Get ResourceLoader object
  • ServletContextAware: Get the ServletContext object in the web application
  • BeanClassLoaderAware: Get the ClassLoader object that loads the current Bean
    insert image description here

Advantages of the Aware interface

  • Various objects and resources in the Spring container can be obtained, such as other beans, file resources, environment variables, etc.
  • Can manage shared resources in the project, such as database connection pool, configuration properties, etc.
  • Deeply integrated with the Spring container, the Bean's behavior can be dynamically adjusted according to the operating environment.
  • Simply and efficiently extend the functionality of Spring Beans.

The difference between ApplicationContextAware and BeanFactoryAware

The difference between these two is rather the difference between ApplicationContext and BeanFactory.

  • ApplicationContext is a sub-interface of BeanFactory, which provides more functions, such as internationalization processing, event propagation, Bean automatic assembly, etc.
  • ApplicationContext is implemented on the basis of BeanFactory, so ApplicationContext that BeanFactory can do can do, but ApplicationContext that BeanFactory cannot do may not be able to do.
  • ApplicationContext is implemented on the basis of BeanFactory, so the performance of BeanFactory is better than ApplicationContext.
  • ApplicationContext is implemented on the basis of BeanFactory, so BeanFactory is more scalable than ApplicationContext.
  • ApplicationContext is implemented on the basis of BeanFactory, so BeanFactory is lighter than ApplicationContext.
  • ApplicationContext is implemented on the basis of BeanFactory, so BeanFactory is more flexible than ApplicationContext.






My Github address , welcome everyone to join my open source project, or (contact me on my homepage) to join your open source project, click Github-Stars.

\ open source project name dependent type version number describe
1 spring-boot-starter-trie pom 1.0.0-SNAPSHOT The query speed under specific requirements far exceeds that of open source search tools, and the B+ tree under innodb or the inverted index in ES cannot compare with it.
2 spring-boot-starter-trie jar 1.0.0-M1 Provides SpringCloud-based service nodes, which can be used for service discovery through the Nacos registry, realizing dynamic expansion and contraction of the tree, and dynamic online and offline services.
3 Data-Provider pom 1.0.0-SNAPSHOT It provides queries from multiple data sources and data type synchronization. As a Jar, it can rely on dynamically providing data on other services.

Guess you like

Origin blog.csdn.net/jj89929665/article/details/130884285