|
16 | 16 | package org.springframework.sbm.boot.upgrade_27_30.report.yaml;
|
17 | 17 |
|
18 | 18 | import com.fasterxml.jackson.core.Version;
|
19 |
| -import com.fasterxml.jackson.databind.ObjectMapper; |
20 | 19 | import com.fasterxml.jackson.databind.module.SimpleModule;
|
21 |
| -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; |
22 |
| -import org.springframework.context.annotation.Bean; |
| 20 | +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; |
23 | 21 | import org.springframework.context.annotation.Configuration;
|
24 |
| -import org.springframework.context.annotation.Primary; |
| 22 | +import org.springframework.context.event.ContextRefreshedEvent; |
| 23 | +import org.springframework.context.event.EventListener; |
25 | 24 | import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper;
|
26 | 25 |
|
27 | 26 | /**
|
| 27 | + * Register module with upgrade report specific yaml deserializers with |
| 28 | + * {@code yamlObjectMapper} Bean declared in {@link org.springframework.sbm.engine.recipe.YamlObjectMapperConfiguration}. |
| 29 | + * |
28 | 30 | * @author Fabian Krüger
|
29 | 31 | */
|
30 | 32 | @Configuration
|
31 |
| -@Primary |
32 | 33 | public class SpringBootUpgradeReportYamlDeserializationConfiguration {
|
33 | 34 |
|
| 35 | + @EventListener |
| 36 | + public void onApplicationEvent(ContextRefreshedEvent event) { |
| 37 | + YAMLMapper yamlObjectMapper = event.getApplicationContext().getBean(YAMLMapper.class); |
34 | 38 |
|
35 |
| - @Bean |
36 |
| - ObjectMapper additionalSpringBootUpgradeReportDeserializer(AutowireCapableBeanFactory beanFactory, ObjectMapper yamlObjectMapper) { |
37 | 39 | SpringBootUpgradeReportSectionHelperDeserializer springBootUpgradeReportSectionHelperDeserializer = new SpringBootUpgradeReportSectionHelperDeserializer();
|
38 |
| - |
39 | 40 | SimpleModule module =
|
40 | 41 | new SimpleModule("SpringBootUpgradeReportDeserializer", new Version(1, 0, 0, null, null, null));
|
41 | 42 | module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, springBootUpgradeReportSectionHelperDeserializer);
|
42 | 43 |
|
43 | 44 | yamlObjectMapper.registerModule(module);
|
44 |
| - return yamlObjectMapper; |
45 | 45 | }
|
| 46 | + |
46 | 47 | }
|
0 commit comments