JacksonAutoConfiguration虽然被排除在外

时间:2014-09-15 07:25:29

标签: spring-boot

我有一个简单的REST服务,它使用的是spring-boot-jersey。我的应用程序看起来像这样:

@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class, SecurityAutoConfiguration.class,
    MongoAutoConfiguration.class, JmxAutoConfiguration.class})
@ComponentScan
public class Application extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}

public static void main(String[] args) {
    new Application().configure(new SpringApplicationBuilder(Application.class)).run(args);
}

}

但是,如果我使用-Ddebug启动服务,我可以看到这些自动配置类仍处于拉入状态:

JacksonAutoConfiguration
  - @ConditionalOnClass classes found: com.fasterxml.jackson.databind.ObjectMapper (OnClassCondition)

JacksonAutoConfiguration.JacksonObjectMapperAutoConfiguration
  - @ConditionalOnClass classes found: com.fasterxml.jackson.databind.ObjectMapper (OnClassCondition)

JacksonAutoConfiguration.JacksonObjectMapperAutoConfiguration#jacksonObjectMapper
  - @ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found no beans (OnBeanCondition)

任何想法为什么会发生这种情况?

1 个答案:

答案 0 :(得分:2)

是。 HttpMessageConvertersAutoConfiguration导入JacksonAutoConfiguration,因此您也必须排除该JacksonAutoConfiguration。可能真的是一个bug,但至少解决方法是显而易见的。你为什么要排除{{1}}?