How to integrate maven into IDEA

How to integrate maven into IDEA

I have never been very familiar with Java, but there is a project that needs to use Maven, so I will learn it by the way and write it as a blog.

1. Operating environment

My running environment is Windows 11, and the Java version is Oracle version 1.8 (try to use Oracle's Java, some problems often occur with openjdk)

2. Configuration method

1. Download and configure environment variables

The first thing is to download maven. The download address is here: https://maven.apache.org/

After the download is complete, you need to unzip it and then configure the environment variables.

First we need to add an environment variable
Insert image description here
, which is MAVEN_HOME

Then add %MAVEN_HOME%\bin in this place

Insert image description here

Then we check it through cmd

mvn -v

The output is

Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: D:\Environment\apache-maven-3.9.1
Java version: 1.8.0_361, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jre1.8.0_361
Default locale: zh_CN, platform encoding: GBK
OS name: “windows 11”, version: “10.0”, arch: “amd64”, family: “windows”

2. Configure MAVEN

First we find the conf folder under your maven folder. There is a settings.xml file in it. We need to modify this file.

We need to add a repo path (the repo folder needs to be created by ourselves)

<localRepository>xxxx</localRepository>

Insert image description here

Then we need to change this source to the Alibaba Cloud source.

The source of Alibaba Cloud is the one below. We can just paste this into the mirror.

<mirror> 
		<id>nexus-aliyun</id> 
		<mirrorOf>central</mirrorOf> 
		<name>Nexus aliyun</name> 
		<url>http://maven.aliyun.com/nexus/content/groups/public</url> 
</mirror>

Insert image description here

Then we still need to modify this place

<profile> 
		<id>jdk-1.8</id> 
		<activation> 
			<activeByDefault>true</activeByDefault> 
			<jdk>1.8</jdk> 
		</activation> 
		<properties> 
			<maven.compiler.source>1.8</maven.compiler.source> 
			<maven.compiler.target>1.8</maven.compiler.target> 
			<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> 
		</properties> 
</profile>

Insert image description here

3.IDEA arrangement

We can create a maven project in this way
Insert image description here

Then you need to make a modification to the settings of IDEA

Insert image description here

Even if the configuration is completed

Guess you like

Origin blog.csdn.net/qq_52380836/article/details/129657313