Xiao Lin’s love affair

One day Xiao Lin is doing nothing to get off work, suddenly hear next door xiao Mei crying, is (Hao) yi (SE) Xiao Lin used to ask concerns “Xiao Mei, how are you? Have you been bullied by manager Wang?” .

Amy sobbed and nodded. “The manager told me to remove the red wavy line from Maven, but I can’t get it off.”

Is (hao) meaning (SE) of xiao Lin thought is a good opportunity to have a meal about the goddess, Xiao Lin immediately said “to me, so late, I finish a meal together?”

Mei looked at Lin and said, “Can you really?”

Xiao Lin patted his chest and said, “Man, why not?”

Mei’s confusion (what is dependency conflict?)

Xiao Lin, look at the screen

 

Obviously, it’s the Fastjson package that’s doing the trick

Kobayashi smiled at Mei and said, “Mei, the red wavy line is due to dependency conflict. If you look at your Fastjson package, does it show omitted for conflict with 1.2.47? It means your Fastjson package has conflict. 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 downloads two versions of C Jar for you, and then they have A dependency conflict, Maven will use the shortest dependency path principle. To decide which version of a JAR to use when another useless JAR is not used. This is called dependency conflict.”

Small beauty excitedly looked at xiao Lin, the eyes reveal a trace of worship 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, “Lin, will you solve it?”

Xiao Lin smiled. “It’s not a problem.”

Come on, show (initial resolution of dependency conflicts)

The solution to dependency conflicts is to use the Exclusion tag provided by Maven. The exclusion tag needs to be placed inside the tag, as follows:

<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

Sure enough, the problem was solved

 

Second hand (batch resolution of dependency conflicts)

Xiao Mei: “Xiao Lin, you are too fierce, I still have a project, can you help me solve the red wavy line? After that, we’ll go downstairs to shaxian Snacks for dinner.”

Kobayashi casually waves his hand, “Little Case”

Xiao Mei opened a new project, and Xiao Lin was completely shocked. There were more than 20 red wavy lines. Xiao Lin thought, “Such a succession of exclusion, all the children of Lao Wang next door could go to Shaxian for soy sauce. It is said that the owner of the official account is still a handsome boy. It would be nice if I could become a person like the owner of the official account, get a promotion and a salary increase, and step on the top of my life.”

Bah. You’re wrong. Let’s help Amy solve her problem.

Kobayashi: “Mei, your project relies on too many conflicts. We’d better use Maven Helper, an Idea plugin, to solve this problem. Many people are using it.

 

Mei: “Wow, it works so well. Can you show me how to download it?”

Kobayashi: “Sure, you can download it by clicking this link. Then, without changing the Idea shortcut key, press Ctrl + Alt + S to open our Settings. Then click On Plguins and select Install plguin from Disk… , select the file we downloaded from the official website. Remember to restart Idea.”

Last time, brother Wang of the project team installed Lombok directly in Idea for me. Although I don’t know what it is, he installed Lombok directly in Idea, which is very good.

Xiao Lin: “I also can!”

  • Again, hold Ctrl + Alt + S to open our Settings, File -> Settings is also available
  • Select Plunins and query Maven Helper. If not, click Search in Repositories
  • Select Maven Helper and click Install

 

  • After the installation, restart IDEA

Maven-help can’t use maven-help

 

Worship + 1 (Idea comes with the method to view dependency conflicts)

Xiao Lin: “Xiao Mei, you understand, this is this, that, that, you can solve the dependency conflict, next I teach you a hand, also very practical oh.”

Mei: “Hello, Xiao Lin, aren’t you too kind?”

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

Kobayashi: “You can look at Maven dependency diagrams this way, that way, that way. The red ones are where the dependencies conflict, and the blue ones are normal dependencies. Of course, you can also Ctrl+Alt+Shift+U to view them.”

 

 

Xiao Lin: “Xiao Mei, let’s go to dinner?”

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

Xiao Lin stayed in place silently, shed tears of tool man!