Not getting the expected version when using the Sp

2019-08-23 19:58发布

问题:

I am in the process of migrating my application to Spring Boot 2.0.4.RELEASE (from 1.5.x) and facing an issue with dependencies management.

I've put my code in a branch here, and it works as expected. I struggled a bit initially to understand why I was getting the 2.8.5 version of gson (more infos here), but in a nutshell :

  • feign-core 9.5.1 pulls gson 2.5
  • this gets overridden by Spring Boot parent dependencies, which sets it as 2.8.5

I build my app, and get a Spring Boot starter to reuse it easily - I use Spring Boot maven plugin to build it, config details here

Now, the problem is when I import that version of the starter in another project, like here : https://github.com/vincent-fuchs/my-custom-github-crawler/commit/8ab128d0ec824b3f0871c175c954a30fe950b88e

when I build my-custom-github-crawler using the starter, it compiles but at runtime, I get an error due to an incorrect version library : I see the gson version, I have is 2.5, not 2.8.5

If I force the gson version in my pom.xml, then it works : https://github.com/societe-generale/github-crawler/blob/sprinBoot2upgrade/github-crawler-core/pom.xml#L20-L24

But surely there's a better way of achieving this, no ? because apart from adding a comment in the pom.xml to my future self saying "forcing this dependency and this version so that it sticks in the starter that we'll build" , I am not sure what to do so that I get the right gson version and it's self-explanatory

Thanks !