我试图理解之间的差异BeanFactoryPostProcessor和BeanPostProcessor.
我理解它BeanFactoryPostProcessor在bean定义上运行,即在bean实例创建之前,它会被执行并BeanPostProcessor在实例化bean并调用生命周期事件后执行.
这是否意味着BeanFactoryPostProcessor不是BeanPostProcessorSpring生命周期事件的一部分,因为它是在实例化之前调用的,而Spring是Spring生命周期事件的一部分吗?请核实我的理解是否正确.
我有一些问题XmlMapper在我的一个Spring Boot项目中自动装配默认的Jackson .我已经创建了一个简单的示例项目来说明这一点.
我在这里做的大致基于这个:
来自pom.xml
<!-- ... -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
</parent>
<!-- ... -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
</dependencies>
<!-- ... -->
Run Code Online (Sandbox Code Playgroud)
主要课程:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
演示POJO,没有指定@XmlRootElement,所以它不会使用JAXB:
@JsonInclude(Include.NON_NULL)
public class Demo {
private String stringProperty;
private int intProperty;
public String getStringProperty() {
return stringProperty;
}
public void setStringProperty(String stringProperty) {
this.stringProperty …Run Code Online (Sandbox Code Playgroud)