Maven environment configuration usage on Eclipse (full)



      Maven environment configuration usage on Eclipse (full)      

1. Install and configure Maven:
  1.1 Download and unzip the Apache Maven from the Apache website http://maven.apache.org/ .
    Maven download address: http://maven.apache.org/download.cgi
  1.2 Configure the configuration file settings.xml in the conf folder of Maven. 

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
    <!--
    Configure the local MAVEN repository location, the default is: C:\Users\machine name\.m2\repository
    <localRepository>D:\Program Files\mvn\</localRepository>  
    ** Eclipse->Windows->Preferences->java->Build Path->Classpath Variables
    -->
    
    <pluginGroups>
    </pluginGroups>

    <proxies>
    </proxies>

    <servers>
    </servers>

    <mirrors>
        <mirror>
            <id>aliyun</id>
            <name>aliyun Maven</name>
            <mirrorOf>*</mirrorOf>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>
    
    <profiles>
    </profiles>
    
    <activeProfiles>
    </activeProfiles>
</settings>
settings.xml

  1.3 Modify settings.xml and add mirror server settings:
      Use the Maven mirror server provided by Alibaba Cloud.
      Alibaba Cloud Mirror Server URL: http://maven.aliyun.com/nexus/content/groups/public/

2. Maven configuration in Eclipse:

?
1
说明:最新版的Eclipse已经内嵌了Mevne插件m2e, 不需要安装Maven插件, 如果不做任何配置,<br>会自动连接使用maven中央库自然可以使用,但是中央库在国外, 受到中国防火墙等因素影<br>响其访问速度很慢, 只有连接到国内镜像库才能提高Maven运行速度. <br>连接到国内镜像库按照如下配置.

   2.1 Open the preference settings of Eclipse
   
    2.2 Find the Maven configuration item
   
    2.3 Set the Maven global configuration file settings.xml
   
    Description: Eclipse will automatically use the URL address information of the mirror library contained in the settings.xml file to find the location of the Maven mirror library.
    2.4 Update the configuration information
   
    2.5 Find the Window menu
   
    2.6 Open the Maven view, check whether
   
    
the use of the mirror library Maven has been configured, and create a Maven desktop project
         1.1 Select the menu to create a Maven project
       
        1.2 Select the skeleton of the project directory structure
       
        1.3 Enter project-related information
       
        1.4 Maven jar project Remarks: Because this step must connect to the Maven server to obtain relevant information, if the configuration
       
    and network are faulty, this step will fail!
       If there is an error, please use a browser to check whether the URL of the Maven server can be accessed.
    2. Create Maven Web Project
        2.1 Select the menu to create a Maven project

       
        2.2 Select the skeleton of the project directory structure
       
        2.3 Enter project related information
       
        2.4 Directory structure of the Maven war project
       
    Note: Because this step must be connected to the Maven server to obtain relevant information, if the configuration and network are faulty, this The step will be wrong!
       If there is an error, please use the browser to check whether the URL of the Maven server can be accessed.
        2.5 Create a Web deployment description file web.xml to eliminate detection errors
       
Search in Eclipse to add Jar component "coordinates"
    Eclipse and Maven provide a powerful jar component integration function.
    1.1 Update the index file
         description of the Maven library:
Mavne index is used to search for jars Component "coordinates", after updating the index, you can search for the jar component "coordinates" in Eclipse, but this function is not necessary.
       
        Note: if you have changed the Eclipse workspace, you need to update the Maven index again;
    1.2 Open the pom in the Maven project. xml file
       
    1.3 Search requires jar component package "coordinates"
       
        Description: This search function is completed by updating the index of the index file of the Maven library in step 1.1. If the index has not been updated, this function will be invalid!!
    1.4 The search result is in the pom.xml file In "coordinates", the jar component will be automatically downloaded when pom.xml is saved.
       
        Note: This search function is done by using the Maven warehouse server. If you cannot connect to the Maven warehouse server, an error will occur!!
        Note: Due to copyright issues, Unable to download the Oracle JDBC Driver 1.5 jar component downloaded by Maven on the public Maven server
    . The component is saved in the ".m2" folder of the local warehouse.
       
    1.6 If there is a download failure, you can check the normal connection of the Maven warehouse and then delete the local warehouse" .m2" and later "Update Maven Projects"
       
Online search Add Jar component "coordinates"
    Aliyun jar component "coordinates" search:http://maven.aliyun.com/nexus/
     1.1 Aliyun jar component "coordinates" search
   
    1.2 There are many search results, select the required component version, find the component "coordinates"
   
    1.3 Copy the found component "coordinates" to the pom.xml file , the jar component is automatically downloaded when the pom.xml file is saved.
   
    1.4 The downloaded jar component is automatically saved in the local library ".m2" folder.
   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324602114&siteId=291194637