|
27 | 27 | import com.netflix.discovery.shared.Applications; |
28 | 28 |
|
29 | 29 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 30 | +import org.springframework.boot.http.converter.autoconfigure.ServerHttpMessageConvertersCustomizer; |
30 | 31 | import org.springframework.context.annotation.Bean; |
31 | 32 | import org.springframework.context.annotation.Configuration; |
32 | 33 | import org.springframework.core.Ordered; |
33 | 34 | import org.springframework.core.annotation.Order; |
34 | 35 | import org.springframework.http.HttpHeaders; |
35 | 36 | import org.springframework.http.HttpStatus; |
36 | 37 | import org.springframework.http.ResponseEntity; |
37 | | -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
38 | 38 | import org.springframework.security.config.Customizer; |
39 | 39 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
40 | 40 | import org.springframework.security.core.userdetails.User; |
@@ -111,15 +111,6 @@ public class EurekaServerMockApplication { |
111 | 111 | .setNamespace("namespace1") |
112 | 112 | .build(); |
113 | 113 |
|
114 | | - /** |
115 | | - * Simulates Eureka Server own's serialization. |
116 | | - * @return converter |
117 | | - */ |
118 | | - @Bean |
119 | | - public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() { |
120 | | - return EurekaHttpClientUtils.mappingJacksonHttpMessageConverter(); |
121 | | - } |
122 | | - |
123 | 114 | @ResponseStatus(HttpStatus.OK) |
124 | 115 | @PostMapping("/apps/{appName}") |
125 | 116 | public void register(@PathVariable String appName, @RequestBody InstanceInfo instanceInfo) { |
@@ -189,6 +180,17 @@ public InstanceInfo getInstance(@PathVariable(required = false) String appName, |
189 | 180 | return INFO; |
190 | 181 | } |
191 | 182 |
|
| 183 | + /* |
| 184 | + * Use this customizer to make sure we use the Jackson mappings for the Eureka server |
| 185 | + */ |
| 186 | + @Bean |
| 187 | + @Order |
| 188 | + ServerHttpMessageConvertersCustomizer customServerConvertersCustomizer() { |
| 189 | + return builder -> { |
| 190 | + builder.jsonMessageConverter(EurekaHttpClientUtils.mappingJacksonHttpMessageConverter()); |
| 191 | + }; |
| 192 | + } |
| 193 | + |
192 | 194 | @Configuration(proxyBeanMethods = false) |
193 | 195 | @Order(Ordered.HIGHEST_PRECEDENCE) |
194 | 196 | protected static class TestSecurityConfiguration { |
|
0 commit comments