• 周六. 10 月 12th, 2024

5G编程聚合网

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

热门标签

Download and install Maven / create Maven project under idea

King Wang

1 月 3, 2022

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
 Insert picture description here
After the download is successful, unzip

02 Configure environment variables

Add environment variables

 Insert picture description here
 Insert picture description here
 Insert picture description here edit path
 Insert picture description here
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

 Insert picture description here

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 .

 Insert picture description here
 Insert picture description here
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 .

 Insert picture description 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 .

 Insert picture description here
Fill in project information .
 Insert picture description here
choice Maven Path and configuration file and warehouse .
 Insert picture description here
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 .

 Insert picture description here

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>

发表回复