gpt4 book ai didi

spring-boot - 尽管排除了 JacksonAutoConfiguration,但仍被拉入

转载 作者:行者123 更新时间:2023-12-04 14:33:41 31 4
gpt4 key购买 nike

我有一个使用 spring-boot-jersey 的简单 REST 服务。我的应用程序如下所示:

@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)

知道为什么会这样吗?

最佳答案

是的。 HttpMessageConvertersAutoConfiguration 导入了 JacksonAutoConfiguration,因此您也必须排除那个。可能真的是一个错误,但至少解决方法是显而易见的。为什么要排除 JacksonAutoConfiguration

关于spring-boot - 尽管排除了 JacksonAutoConfiguration,但仍被拉入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25842808/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com