Xiao Lin’s romance

This day xiaolin idling prepare to go off work, suddenly hear next door small beauty is crying, is (hao) righteousness (SE) of xiaolin past concern of ask “small beauty, what’s wrong with you? Was he bullied by the damned manager Wang?” .

Mei sobbed and nodded. “The manager told me to get rid of Maven’s red wavy lines, but I can’t get them out.”

Hao Yi (se) xiao Lin thought it would be a good chance to have dinner with the goddess. Xiao Lin immediately said, “I’ll take care of it. It’s so late.

Mei looks at Xiao Lin and says, “Can you really?”

Xiao Lin clapped her chest and said, “Man, what can’t I do?”

Mei’s confusion (what is dependency conflict?)

Xiao Lin, look at the screen

Obviously, the fastJSON package is the culprit

The red wavy line is due to dependency conflict. omitted for conflict with 1.2.47 is displayed in your fastJSON package. Let me put it another way. For example, if your project uses A jar that depends on C Jar, and B Jar that depends on C JAR, Maven will download two versions of C Jar for you, and then they will have A dependency conflict. To decide which version of the JAR to use, and another useless JAR is not used. This is called a dependency conflict.”

The small United States is excited of looking at xiao Lin, the look in the eyes reveals a trace of worship of the look in the eyes.

Xiaolin made a merry heart, and then said: “in fact, in most cases, the jars conflict is will not affect the normal operation of our system, but has not ruled out will appear in some extreme situations could not find the exception class, we, as a rigorous programmers (for KPI), must to solve this problem”

Mei nodded in agreement and said, “Xiao Lin, will you fix it?”

Xiao Lin smiled. “No problem.”

Come on, show (preliminary resolution of dependency conflict problem)

The solution to this dependency conflict is to use the Exclusion tag provided by Maven. The Exclusion tag needs to be placed inside the tag, like this:

<dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
 <exclusions>
  <exclusion>
 <artifactId>fastjson</artifactId>  <groupId>com.alibaba</groupId>  </exclusion>  </exclusions> </dependency> Copy the code

The problem was solved.

A second hand (resolve dependency conflicts in bulk)

Small beauty: “small forest, you too fierce, I this still have a project, you can all help me solve next red wave line? After we solve the problem, we will go to the downstairs Shaxian snack for dinner.”

Xiao Lin waved his hand casually, “Small case”

Xiao Lin thought, “Such an exclusion, the children of Lao Wang next door can go to Shaxian to get some soy soy. Fortunately, I followed The Code Du Du Bike. This official account not only has the latest interview questions of Dafang in 2020, but also various e-books. Technical documents, more look at the public number of technical articles, no longer need to be afraid of being manager Wang, it is said that the public number is still a handsome man, if I can also become the number of people like that, promotion and salary increase, on the peak of life”

Bah. That’s wrong. Let’s help Mei out.

Xiaolin: “Mei, your project relies too much on conflict. We’d better solve this problem with Maven Helper Idea plugin. A lot of people use it.

Small beauty: “wow, so good to use, that you can teach me how to download?”

“Sure, you can click on this link to download it. Then, without changing Idea, press Ctrl + Alt + S to open our Settings. Then click Plguins and select Install plguin from Disk… “, select the file we downloaded from the official website, remember to restart Idea oh”

The small United States: “good trouble, last time the project team wang brother directly in the Idea to help me install Lombok, although I do not know what it is, but he is directly in the Idea inside the installation, super powerful”

Xiao Lin: “I also can!”

  • Again, hold Ctrl + Alt + S to open our Settings and select File -> Settings

  • Select Plunins, look for Maven Helper, if not, click Search in Repositories

  • Select Maven Helper and click Install

  • Restart IDEA after the installation is complete

(Maven-help)

Worship + 1 (Idea comes with a way to view dependency conflicts)

Small forest: “small beautiful, you understand, be such such, like that, can solve rely on conflict, next I teach you one hand, also very practical”

Small beauty: “good, small forest, you person also too good”

Xiao Lin: “What? Is this a good guy card?”

Kobayashi: “You can look at the dependency diagram of Maven this way and that way. The red ones are where the dependencies collide, and the blue ones are where the dependencies are normal. You can also Ctrl+Alt+Shift+U and view them.”

Xiao Lin: “Xiao Mei, shall we have dinner?”

Small beauty: “can, but downstairs sand county closed, we next time, I first work home”

Xiao Lin silently stay in situ, shed the tears of the tool man!

The END!

This article was typeset using MDNICE