Installing and configuring MAVEN environment variables
Set HTTP Proxy
(prior to installing the Maven plugin in eclipse failed many times, I do not know if the reason for not setting up the HTTP proxy before, so it is better to configure it)
First in the cmd
input: ping repo1.maven.org
, if you can not ping the same, you must first set up the agent, set up the way:
Enter the directory ~/.m2/
directory, locate the settings.xml
file (if not, %M2_HOME%/conf/settings.xml
copy it directly to the directory), and <proxies>
add the following information to the tag:
<Proxies><Proxy><Id>my-proxy</Id><Active>true</Active><Protocol>http</protocol> < host>114.212.80.250</host> Span class= "Hljs-tag" ><port>80</ port> <username>park</username> < Password>****</password> << Span class= "Hljs-name" >nonproxyhosts>www.park.com|*.host.com</ nonproxyhosts></PROXY>
Where the label is changed to its own IP address, host name and password.
Configuring Maven in Eclipse
- Open Eclipse, tap the
Help
tab, tap Install new software
, and select Add
options:
Name
Enter in field: m2e
;
Location
Enter in field: http://download.eclipse.org/technology/m2e/releases
;
- Select the Maven plugin from search, then click Next.
- Installing the plug-in may take a while to restart Eclipse.
Create a MAVEN project in eclipseIn Eclipse, click File -> New -> Others -> Maven Project
Create your own MAVEN project.
Enter your own name at Groupid,artifactid, as shown in:
- Group Id: Defines which group the project belongs to, which is often associated with the organization or company where the project is located. For example, Apache has created a project named Mymaven, then GroupID is: com.apache.myMaven;
- Artifact ID: Defines the unique ID of the current MAVEN project in the group. For example, the project Com.apache.myMaven has the following artifactid:mymaven-util, Mymaven-domain, Mymaven-web and so on;
Eclipse automatically generates MAVEN projects, directory structure:
Directory Analysis:
src/main/java
: This directory mainly places Java source code;
src/test/java
: This directory is mainly used to store test code;
Maven Dependencies
: This is where Maven managed jar files are mainly placed;
target
: Used to store maven compiled bytecode files;
pom.xml
: All called Project Object Model
, the Project object model, which defines the basic information of the project, describes how the project is built, declares the project dependencies, and so on.
src
: Used to store resources such as other files that are used in main and test.
In the App.java in the src/main/java
directory, there is already a HelloWorld.java
simple applet that can be tested and run.
PackagedYou can pom.xml
specify the type to package in, and the default is if unspecified .jar
.
The packaging process is: Under the project root directory, execute the command mvn clean package
, and then you can ./target/
find the package that you just packaged in the directory jar
.
This completes the MAVEN installation, how to create a new MAVEN project in Eclipse, and how to package the project, followed by a practical project to further understand Maven.
Maven Learning (i)--installing MAVEN and configuring Maven in eclipse