Installation configuration method for "Javaweb development" maven (Eclipse)

Source: Internet
Author: User
Tags naming convention unique id

MAVEN is primarily used to resolve dependencies between jar packages, such as when using the STRUTS2 framework, when you introduce Apache's struts2 jar package, there is a dependency between the jar packages, and you need to import additional jar packages. This time if you use MAVEN to configure, then its dependent jar package will not need you to manually re-import. Of course I use MAVEN to build SPIRNGMVC, this article is mainly about MAVEN build, SPRINGMVC will write blog alone.

The first step is to download maven
 官网直链:https://maven.apache.org/     下载tar.gz文件或者.zip文件均可。
Step two, unzip maven
解压到本地硬盘中,建议选择系统盘或其他软件安装盘。
Step three, install Maven
  • To configure environment variables:

    1. New environment variable:
      1. Variable name: m2_home
      2. Variable value: The Maven path extracted in the second step, for example: C:\Program files\apache-maven-3.3.
    2. To edit the PATH environment variable:

      1. Add a new variable and be careful not to delete the value of the other path variable when editing m2_home.
      2. Environment Variables Test directives:

        • Console: Mvn-version
        • The following similar content appears to be successful:
          apache Maven 3.3  .9  (BB52D8502B132EC0A5A3F4C09453C07478323DC5; 2015  7  +08 : 00 ) Maven Home: c : \program Files\apache-maven-3.3  Span class= "Hljs-number" >.9 Java version: 1.8  .0  _92, Vendor:oracle Corporationjava home: c : \program Files\java\jdk1.8  .0  _92\jreDefault  LOCALE:ZH_CN, platform Encoding:gbkos name:  "Windows 7" , Version:  "6.1" , Arch:  "AMD64" , Family:  "dos "
Fourth step, modify MAVEN's configuration file

Go to the CMD console and enter the following commands in turn:

  1. CD C:\Users\Administrator

    If your user name is not the default, you need to change the administrator, this command means to enter the current user's file list

  2. mkdir. M2

    This instruction is to create a folder under the current path, the name of the folder is. M2 be careful not to miss out on this point .

  3. Copy the configuration file settings.xml (path/conf/settings.xml) file in the Maven decompression file to the directory and modify its contents to:

    explanation : Actually, when you run MAVEN, it will automatically be in this C:\Users\. A. M2 folder is generated under the administrator path, where manually generated and copied settings.xml files are primarily designed to avoid the hassle of upgrading Maven later.

      1. Main changes two places:
        1. First place:
          Here is the default installation address of the jar package, and if you do not set it, it will be downloaded to the default path, which is: C:\Users\Administrator.m2\repository folder
      2. A second place:
        This is the mirror station, because the official server access to more people, the central warehouse sometimes will refuse your visit or other reasons often slow, so the official recommended us to use the United Kingdom UK mirror Station, but I do not test the ladder is a very troublesome thing, So if the students do not have a ladder may need to find the address of the mirror station, but I still suggest that the developers to buy ladders to configure, not a variety of strange problems oh.
        finally attached I use the settings.xml file code, easy to reach the party. (need to look down on the UK mirror station)
    <?xml version= "1.0" encoding= "UTF-8"?><!--Licensed to the Apache software Foundation (ASF) under Oneor more contributor License AG  Reements.  See the NOTICE filedistributed with this work for additional informationregarding copyright ownership. The ASF licenses this fileto you under the Apache License, Version 2.0 (the "License");  Except in Compliancewith the License. Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or Agreed to Writing,software distributed under the License are distributed on a "as is" BASIS, without warranties OR Condi  tions of Anykind, either express or implied. See the License for Thespecific language governing permissions and limitationsunder the License.--> <!--| The configuration file for Maven.  It can specified at levels: | | 1. User level.                 This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml.                 | |                 Note:this location can is overridden with the CLI option: | |  -s/path/to/user/settings.xml | | 2. Global level.                 This settings.xml file provides configuration for all Maven |                 Users on a machine (assuming they ' re all using the same Maven | installation).                 It ' s normally provided in | ${maven.home}/conf/settings.xml.                 | |                 Note:this location can is overridden with the CLI option: | | -gs/path/to/global/settings.xml | | The sections in this sample file is intended to give you a running start at | Getting the most out of your Maven installation. Where appropriate, the default | VALUES (values used when the setting are not specified) is provided. | |--><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 ">                      <!--localrepository |   The path to the local repository maven would use to store artifacts.   | | Default: ${user.home}/.m2/repository Use defaults <localRepository>/path/to/local/repo</localRepository>-- >  <!--Interactivemode | This would determine whether Maven prompts when it needs input. If set to False, | Maven would use a sensible default value, perhaps based on some other setting, for |   The parameter in question.   | | Default:true <interactiveMode>true</interactiveMode>  <!--Offline |   Determines whether MAVEN should attempt to connect to the network when executing a build. |   This is a effect on artifact downloads, artifact deployment, and others.   | | Default:false <offline>false</offline>  <!--plugingroups |   This was a list of additional group identifiers that would be searched when resolving plugins by their prefix, i.e. | When invoking a command line like "Mvn prefix:goal". Maven would automatically add the group identifiers |   "Org.apache.maven.plugins" and "Org.codehaus.mojo" if these is not already contained in the list. |-->  <plugingroups>    <!--Plugingroup |    Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup>  </plugingroups>  <!--proxies |   This is a list of proxies which can being used on the the network. | Unless otherwise specified (by system property or command-line switch), the first proxy |   Specification in this list marked as active would be used. |-->  <proxies>    <!--Proxy |     Specification for one proxy, to is used in connecting to the network.    | <proxy> <id>optional</id> <active>true</active> <protocol>http</prot ocol> <username>proxyuser</username> <password>proxypass</password>   </proxies>  <!--Servers |   This was a list of authentication profiles, keyed by the Server-id used within the system. |   Authentication profiles can is used whenever Maven must make a connection to a remote server. |-->  <servers>    <!--Server | Specifies the authentication information to use if connecting to a particular server, identified by |     A unique name within the system (referred to by the ' id ' attribute below).     | |       Note:you should either specify Username/password OR privatekey/passphrase, since these pairings are |     Used together.    | <server> <id>deploymentRepo</id> <username>repouser</username> <PASSWORD&G T;repopwd</password> </server>    <!--Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> &L t;passphrase>optional; Leave empty if not used.</passphrase> </server> --  </Servers>  <!--Mirrors |   This was a list of mirrors to being used in downloading artifacts from remote repositories.   | |   It works like This:a POM could declare a repository to use in resolving certain artifacts. | However, this repository is problems with heavy traffic at times, so people has mirrored |   It to several places.   | | That repository definition would has a unique ID, so we can create a mirror reference for that | Repository, to is used as an alternate download site. The mirror site would be the The preferred |   Server for that repository. |-->  <mirrors>    <!--Mirror | Specifies a repository mirror site to use instead of a given repository. The Repository that | This mirror serves have an ID, that matches, the mirrorof element of this mirror. IDs is used |     For inheritance and direct lookup purposes, and must is unique across the set of mirrors.    | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>huma N Readable Name for this mirror.</name> <url>http://my.repository.com/repo/path</url> </mirro R> --     <!--using the British mirror official recommendations- -     <mirror>     <ID>UK</ID>     <name>UK Central</name>     <URL>Http://uk.maven.org/maven2</URL>     <mirrorof>Central</mirrorof>    </Mirror>  </mirrors>  <!--Profiles | This is a list of profiles which can being activated in a variety of ways, and which can modify | The build process. Profiles provided in the settings.xml is intended to provide local machine-|   Specific paths and repository locations which allow the build to work in the local environment.   | | For example, if you have a integration testing plugin-like cactus-that needs to know where | Your Tomcat instance is installed, you can provide a variable here such that's the variable is |   dereferenced during the build process to configure the Cactus plugin.   | | As noted above, profiles can be activated in a variety of ways. One way-the activeprofiles | section of this document (Settings.xml)-'ll be discussed later. Another-essentially | Relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also is activated by JDK version prefix, where a | Value of' 1.4 ' might activate a profile when the build was executed on a JDK version of ' 1.4.2_07 '. |   Finally, the list of active profiles can specified directly from the command line.   | |       NOTE:FOR profiles defined in the settings.xml, you is restricted to specifying only artifact |       Repositories, plugin repositories, and Free-form properties to be used as configuration |   Variables for plugins in the POM.   | |-->  <profiles ;      <!--profile | Specifies a set of introductions to the build process, to is activated using one or more of the | Mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> |     or the command line, profiles has an ID of that is unique.     | | An encouraged best practice for profile identification are to use a consistent naming convention |     For profiles, such as ' Env-dev ', ' env-test ', ' env-production ', ' User-jdcasey ', ' User-brett ', etc. | This'll make it more intuitive to understand what's the set of introduced profiles is attempting |     To accomplish, particularly if you are only having a list of profile IDs ' s for Debug.     | |    This profiles example uses the JDK version to trigger activation, and provides a jdk-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </acti Vation> <repositories> <repositorY> <id>jdk14</id> <name>repository for JDK 1.4 builds</name> <url >http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotpolic y>always</snapshotpolicy> </repository> </repositories> </profile>-    <!--| Here is another profiles, activated by the system property ' Target-env ' with a value of ' Dev ', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration |     Might hypothetically look like: | | ...     |   <plugin> |   <groupId>org.myco.myplugins</groupId> |     <artifactId>myplugin</artifactId> |   |     <configuration> |   <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> |     ...     | |       Note:if just wanted to inject the configuration whenever someone set ' target-env ' to |     Anything, you could just leave off the <value/> inside the activation-property.    | <profile> <id>env-dev</id> <activation> <property> <name>tar get-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties&gt    ; </profile>  </Profiles>  <!--activeprofiles |   List of profiles that is active for all builds.  | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile> Anotheralwaysactiveprofile</activeprofile> </activeProfiles></Settings>
Fifth step, Eclipse integrated maven
    1. To download a suitable version of Eclipse, the version of Eclipse I am using is j2ee4.6.0. If you can't find the MAVEN option later in the steps, please load Maven's plugin yourself or choose to upgrade the Eclipse version.
    2. Enter the configuration in Eclipse.

      1. Configure the installation path for MAVEN: Click on the right side of ADD, click Directory, Preferences, Maven-Installations, windows n the path to the extracted files (very similar to Tomcat configuration OH)
      2. Configure MAVEN's profile path: Click Browse and locate Maven configuration file (settings.xml), User Settings, maven-Preferences, Window, then find it.

This post is compiled from www.imooc.com

Installation configuration method for "Javaweb development" maven (Eclipse)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.