table of Contents
1. automatically create a maven project
- Open website https://start.spring.io/
Click generate, unzip the downloaded item
2. Modify the IDEA default remote repository, improving download speed dependencies
Ali cloud the remote repository instead of a mirror- Open the IDEA File-> settings-> ... -> Maven, find the directory settings file maven settings.xml, as the figure "1."
- 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
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:
- IDEA has been stuck in downloading dependencies
- After stopping downloading dependencies, java code-dependent error displayed in red, as @SpringBootApplication, require increased or downloaded jar package Annoation
IDEA display error:
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom: ..*.RELEASE
Solution:
- The maven local repository (the position as in FIG. 2) of the dependent packages the item deleted
- IDEA clean up cache and restart, Files -> Invalidate Caches and restart -> Invalidate and Restart
- After rebooting the remote repository IDEA remember modified in accordance with the above method
- Modify dependent maven to automatically download (or manual selection maven introduced, open the context menu on the pom.xml project, Maven -> Reimport)
- IDEA will show downloading dependencies