Solve the problem that IDEA reports an error after creating a Maven project and the src folder does not appear

When creating a new Maven project, I found that an error occurred after creation, and the src folder did not appear. The situation is as follows:

Friends, please think about whether your maven meets the following conditions:

1. The Maven that comes with IDEA is not used, but the Maven that is independent on a certain disk.

2. Your maven is independent, and the plug-ins in the repos folder (local warehouse) in your Maven are unzipped by others.

3. Have you modified the settings.xml file in your maven?

 If you have one of the above situations, please see the following solutions:

1. IDEA itself comes with Maven. In fact, we do not need to reinstall Maven. The Maven that comes with IDEA will not have any errors. Its user configuration file and local warehouse are on the C drive by default. If you do not want the local warehouse To occupy the C drive path, you can create a new folder under another drive for warehouse use, and then rewrite the local warehouse path when creating a new project.

Now create a new project and go to the page to select Maven and user settings files and local warehouse.

Determine whether to use Maven that comes with IDEA: The main Maven path is displayed as: Bundled (Maven3) or Bundled (Maven3)

 The user settings file remains unchanged and the local warehouse path is rewritten (mine is written under the D drive, you can just create a new folder yourself) 

 At this time, click to complete the creation. Maven that comes with IDEA will automatically download the required plug-ins. After it is downloaded and cached, a small green √ will appear, indicating that the creation is successful and the src folder will also appear. (The first download may be a little slow. It depends on your network. Wait patiently! If it is still spinning in circles, it is not completely healed. You have to wait until "The process has ended and the exit code is 0" to be considered complete!)

 

 At this time, src appears (I'm really sorry that the watermark is a bit obscured. I don't know how to remove this watermark. I found some tutorials to no avail. If anyone knows, please give me some advice. Thank you!! QAQ)

 PS: There may be a warning below. I haven't found a good solution yet, but I found that it doesn't affect my use so far. If anyone knows the solution, please give me some advice!

 2. The files in the repos given to you by others may be inconsistent with the configuration of your mirror, so they cannot be recognized. I think the most intuitive way is to ask Maven to re-download the contents of the repos folder in your local maven first. Delete them all, and then select Bundled (Maven3) or Bundled (Maven3) in the Maven main path. The configuration file does not change, and the local warehouse is changed to the repos folder in your local Maven.

You also need to wait for re-downloading, it will re-download the plug-in that matches your mirror configuration. After waiting for it to download, it will basically be fine. But there may be some warnings (the main problem is that some plug-ins are not found). If you re-create a project according to this configuration, Maven will directly continue to download the plug-ins you need, and you will be successful in the future! (The network in the laboratory is very poor, so it runs slowly. Sorry)

After downloading some plug-ins in this way, when you create a new project in the future, you can try to change the Maven main path to your own independently installed Maven, and also modify the user settings file to your independently installed Maven. Generally, at most, there will only be a warning but no error, and no src will appear. folder (the content of the warning is basically the same as above, please see if there is any good solution? I have tried a lot but it seems to be useless. The most stable one is to use the maven that comes with IDEA)

 

 Note: Under independently installed Maven, failure to create is also related to your settings.xml file! If src still does not appear in such an independent installation configuration and an error is displayed in the run box, there is probably a problem with your settings.xml file! Please recall whether you modified the content inside.

3. If you have modified Maven's settings.xml, please try to recall where you modified it, check whether the path to your local warehouse is incorrect, and check whether the mirror configuration is incorrect. (Generally speaking, the path pointed by computers with Internet access is Alibaba Cloud's mirror warehouse) If you accidentally modify the mirror, the following is the code pointing to Alibaba Cloud's mirror warehouse:

<mirror>
  <id>nexus-aliyun</id>
  <mirrorOf>*</mirrorOf>
  <name>Nexus aliyun</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

So the problem here is that it is possible that the files in the repos given to you by others are different from your mirror configuration, which leads to the problem that Maven cannot find the plug-in.

In fact, if you are already using IDEA and want to use Maven, you do not need to install it separately. IDEA itself comes with Maven. Just rewrite the warehouse path. There is no need to install Maven (I was asked to ..Looking back now, it was really too much!)

The above are the solutions we found. I have to say that I have also tried many methods on the Internet, but they are of no use. This is how it was finally resolved.

My friend said that half of the blame for Maven's error reporting should be shouldered. (Because the error always said it was because the mirror warehouse could not be linked, we looked for it in the local warehouse (which also failed), so we were looking for problems with the warehouse at the beginning)

At the end, I would like to thank my friends who helped me solve this problem! ! ! After working hard for more than 3 hours, I finally got it done! grateful! !

I hope this article can also help everyone who is having this problem!

Good night!

Guess you like

Origin blog.csdn.net/m0_53101456/article/details/129858875