• 周六. 10 月 5th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Idea is slow to create Maven project? Don’t worry. There are three options

King Wang

1 月 3, 2022

troubled

Intellij idea Is a very powerful editor , It’s easy to create for us maven project , Those of you who have had this experience should have experienced it , But there is always a problem , That’s using idea establish maven Project time , slowly , It often takes several minutes , Sometimes it even gets stuck , The main reason is creation maven The default is to download a file on the network archetype-catalog.xml, The file size has 5-6M, The download was slow , This causes the creation process to be slow .

terms of settlement

There are three solutions , And they all need to be right maven Of VM Options Parameter configuration .

Method 1

stay maven Of VM Options add -DarchetypeCatalog=internal Parameters , Steps are as follows :

open idea Startup interface , Go global
 Insert picture description here Search for maven, Click on Runner One column , stay VM Options In the input field “-DarchetypeCatalog=local”,

 Insert picture description here after , New again maven project , You’ll see that the project is created quickly .

Method 2

download archetype-catalog.xml file , stay maven Of VM Options add -DarchetypeCatalog=local

By default , establish maven The project is downloaded from the network catalog file , We can catalog File down to local , And then by setting archetype Is used as local, So you don’t have to download it from the Internet every time .

step :

1、 download archetype-catalog.xml File to local .

The location of the file is http://repo1.maven.org/maven2/archetype-catalog.xml, But direct access is not downloadable , I put the file there github On , Those who need it can download it .

https://github.com/Taoxj/sc_properties

2、 After downloading, put it in the corresponding location in the local warehouse

maven Location of local warehouse with settting.xml About configuration in , For example, I setting.xml The location of the configuration repository is :D:\apache-maven-3.6.0\repository
 Insert picture description here
that catalog The file can be put D:\apache-maven-3.6.0\repository\org\apache\maven\archetype\archetype-catalog\3.0.1 Next
 Insert picture description here
If setting.xml No warehouse location is configured , Just place it under the default local repository . The default location for the local repository is :Default: ${user.home}/.m2/repository, For example, my computer user name is Administrator, The warehouse location is C:\Users\Administrator.m2\repository.

3、 modify maven Of VM Options Parameters

The steps are the same as in the previous method , Open in global Settings maven Set the bar , And then in VM Options Fill in the input box

-DarchetypeCatalog=local

such maven Each time it gets it locally catalog file , You don’t have to wait that long to create a project .

Method 3

stay maven Of VM Options add -Dmaven.multiModuleProjectDictory=$MAVEN_HOME Parameters ,MAVEN_HOME Configuration in your environment variables maven Name of environment
 Insert picture description here
After setting the parameters , newly build maven Add parameters to the project archetypeCatalog, The value is internal, Or if you have it in your local warehouse catalog file , The parameter value can also be local
 Insert picture description here After determining ,maven The project can be built very quickly .

Experience

So that’s the solution idea establish maven Several options for slow projects , It’s worth noting that , Not all three are effective , For example, I have tried the first two , Discover that the company’s computers can succeed , The home computer doesn’t work , Then I tried the third option , Discovery or failure , I checked the Internet to find out , Turned out to be jdk and maven Version incompatibility problem .

two-computer jdk Version are 1.8 Of , But it was installed on my company’s computer maven The version is 3.5, Personal computers are installed with 3.3 Of maven edition , So I installed the same on my personal computer 3.5 Of maven edition , Try the third option again , And it worked , Excited, I tried the first two on my personal computer , I still can’t solve the problem , And until now I don’t know why , but , It can only be studied later .

Finally, some Suggestions , Readers can try the first two first , Because once and for all , You don’t need to configure the parameters when you create the project , If that doesn’t work, take the third option .

发表回复