3
votes

We have a quite big project based on Spring with an API returning json data by default. As soon as we add the azure-storage-blob library dependency in maven pom, all the controllers instead of returning json by default, are returning xml. I remove the dependency, and back to json.

Seems to be linked with Jackson dataformat, cause when I exclude it :

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-storage-blob</artifactId>
    <version>10.3.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </exclusion>
    </exclusions>
</dependency>

goes back to json.... but azure does not work anymore :)

Do you have any ideas how to deal with that ?

Thanks and have a lovely day

Edit 2018-01-07 : Jackson is an old friend, and I added spring configuration to force json as a fallback format, by it is not ideal:

@Override public void configureContentNegotiation(ContentNegotiationConfigurer conf) { 

    conf.favorPathExtension(true)
        .favorParameter(false)
        .ignoreAcceptHeader(true)
        .useJaf(false)
        .defaultContentType(MediaType.APPLICATION_JSON);
}

This works partialy as some side effects are coming

1
Hello. I am stuck with the same problem, did you find a better solution, to avoid the side effects? Thanks! - dleal
Hi, I haven't looked up for fallback, for now we don't have issues with this solution :) - Julien Revault d'A...
Thanks for the quick response. I'm not sure I follow...how did you fix the issue? I mean, you have Azure in your project, right? How did you make it work with JSON instead of XML? I haven't been able to find the right configuration, tried even creating a @Bean for ObjectMapper, but somehow I still see XML. Thanks - dleal

1 Answers

0
votes

It looks like you may have to use com.fasterxml.jackson.core per the Azure-storage-java documentation it is what's used to parse data to Json. I'd also suggest checking this documentation regarding Jackson core which may help as well.