Maven Download and install / stay IDEA Create Maven project
** stay JavaWeb The development of , As the project gets bigger , Corresponding , The project management also becomes very complicated . If there is a tool to manage projects , It will greatly simplify some trivial work such as package guide . **
01 Download and install
Download address :http://maven.apache.org/download.cgi
After the download is successful, unzip
02 Configure environment variables
Add environment variables
edit path
Type… In the command window mvn -v See if the environment variable is successful , If there is a graphic result , Indicating successful configuration , Go to the next step
03 Modify the configuration file
because maven The default warehouse path is c disc , Here, reconfigure the following warehouse Path , The first thing you need to do is maven Create a new one in the directory repository
Empty directory , open maven Install under directory conf
Catalog , modify settings.xml
file .
because Maven The default node of is overseas , For convenience jar Package download , You need to configure an image file , Alibaba cloud image is used here .
Here we are ,Maven Installation of is complete .
04 Use IDEA establish Maven
First , open IDEA Create a new project . Check the options in the figure to create .
Fill in project information .
choice Maven Path and configuration file and warehouse .
After entering the project , In the lower right corner, select auto Guide Package . Wait a while , When the console shows the graphic result , It means success .
05 Use Maven management JAR package
Whatever you use jar package , All need to go to pom.xml Middle configuration ; Here we use junit For example .
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Recommend to Maven Download what you need in the central remote warehouse JAR package , Attached address :https://mvnrepository.com/
06 common problem
The project can be in IDEA Run in , But can’t publish , Maybe it’s because there’s no resource filter configured . Need to be in pom.xml Add the following configuration :
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>