BeanPostProcessor是一个接口,有两个方法:postProcessBeforeInitialization、postProcessAfterInitialization,这两个方法每个bean创建都会执行一次。

  postProcessBeforeInitialization在属性设置后,init方法执行前执行,postProcessAfterInitialization在属性设置后,init方法执行后执行。请看示例:

  pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.edu.spring</groupId>
    <artifactId>spring</artifactId>
    <version>1.0.0</version>

    <name>spring</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.2.RELEASE</version>
        </dependency>
    </dependencies>

</project>
View Code

相关文章:

  • 2022-12-23
  • 2021-06-23
  • 2021-08-06
  • 2021-12-09
  • 2021-10-19
  • 2021-10-28
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2022-02-06
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
相关资源
相似解决方案