In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "using SpringBoot to exclude automatic assembly of a class to resolve jar package conflicts", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "use SpringBoot to exclude automatic assembly of a certain class to solve jar package conflicts"!
recently, when docking with a third party platform, due to the fact that the other party's restful api is not perfect, we were forced to choose sdk mode.
Sure enough, when using SpringBoot integration sdk, encountered a headache jar package conflict.
The other party's core jar package depends on gson-2.2.4.jar, which conflicts with the higher version gson that SpringBoot itself depends on, causing SpringBoot to fail to start under the lower version gson:
Caused by: java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
Start resolving conflicts...
First of all, in pom excluded third-party companies rely on gson-2.2.4.jar, SpringBoot can start normally. However, the SDK does not work with older versions of GSON:
Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonObject;
Therefore, I want to lower the version of SpringBoot, and then lower the version of gson it depends on, and finally found that the oldest SpringBoot 1.4 depends on gson has reached 2.7, this path is not working.
At this point, it seems that we can only contact the third party company, let the other party upgrade gson and then re-type jar package sent over.
To be determined...
During this period, I have been wondering a question: "springboot uses jackson's json library by default, why use gson when starting?" "
Finally, after a person dial, to solve the puzzle: springboot does not use gson, but boot will automatically assemble it for standby.
If you don't want to, you can exclude automatic assembly by:
@SpringBootApplication(exclude = {GsonAutoConfiguration.class})
SpringBoot is equipped with a lot of classes at startup, see spring-boot-autoconfiguration-2.x.x.RELEASE.jar for details, and exclude those that are not used.
At this point, I believe that everyone has a deeper understanding of "using SpringBoot to exclude automatic assembly of a class to resolve jar package conflicts". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.