Maven project into Intellij IDEA

1. automatically create a maven project

  1. Open website https://start.spring.io/
  2. Click generate, unzip the downloaded item
    Here Insert Picture Description

    2. Modify the IDEA default remote repository, improving download speed dependencies

    Ali cloud the remote repository instead of a mirror
  3. Open the IDEA File-> settings-> ... -> Maven, find the directory settings file maven settings.xml, as the figure "1."
    Here Insert Picture Description
  4. Ali added cloud mirrored in the settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!--加入以下内容-->     
    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus-aliyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
</settings>

3. Modify the IDEA provided maven

Here Insert Picture Description

4. maven project into IDEA

Use IDEA's Open function, select the file you want to import maven project in the pom.xml file, follow the prompts to select AS A Project Open , IDEA will automatically download the dependent packages according to dependencies in the project

Pit: IDEA can not download dependencies

The foregoing steps need to be performed in the order 1-4.
If the first import a maven project, IDEA has been displayed in downloading dependencies, and then far as to set up a remote repository and modify settings maven, is not going to solve the problem! ! !
The reason is that after the import maven project, maven local repository will depend download remaining unfinished , then even if modify the remote repository, IDEA will still be based on the configuration caches continue downloading from the default warehouse remaining dependent! ! !

Possible errors are as follows:

  1. IDEA has been stuck in downloading dependencies
  2. After stopping downloading dependencies, java code-dependent error displayed in red, as @SpringBootApplication, require increased or downloaded jar package Annoation
  3. IDEA display error:

    Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom: ..*.RELEASE

Solution:

  1. The maven local repository (the position as in FIG. 2) of the dependent packages the item deletedHere Insert Picture Description
  2. IDEA clean up cache and restart, Files -> Invalidate Caches and restart -> Invalidate and Restart
  3. After rebooting the remote repository IDEA remember modified in accordance with the above method
  4. Modify dependent maven to automatically download (or manual selection maven introduced, open the context menu on the pom.xml project, Maven -> Reimport)
  5. IDEA will show downloading dependencies

Guess you like

Origin www.cnblogs.com/ChengzhiYang/p/12402696.html