maven 处理无法下载jar包方法

来源:互联网 发布:淘宝的生意参谋是什么 编辑:程序博客网 时间:2024/06/05 14:59
  1. 设置eclipse 插件 m2eclipse,依次选择window->preferences->Maven,详细设置如下图所示
    [html] view plain copy
     print?
    1.   
  2. 修改\apache-maven-3.1.0\conf目录下的setting.xml文件,加入镜像文件地址,setting.xml文件如下所示
    [html] view plain copy
     print?
    1. <?xml version="1.0" encoding="UTF-8"?>  
    2.   
    3. <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor   
    4.     license agreements. See the NOTICE file distributed with this work for additional   
    5.     information regarding copyright ownership. The ASF licenses this file to   
    6.     you under the Apache License, Version 2.0 (the "License"); you may not use   
    7.     this file except in compliance with the License. You may obtain a copy of   
    8.     the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required   
    9.     by applicable law or agreed to in writing, software distributed under the   
    10.     License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS   
    11.     OF ANY KIND, either express or implied. See the License for the specific   
    12.     language governing permissions and limitations under the License. -->  
    13.   
    14. <!-- | This is the configuration file for Maven. It can be specified at two   
    15.     levels: | | 1. User Level. This settings.xml file provides configuration   
    16.     for a single user, | and is normally provided in ${user.home}/.m2/settings.xml.   
    17.     | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml   
    18.     | | 2. Global Level. This settings.xml file provides configuration for all   
    19.     Maven | users on a machine (assuming they're all using the same Maven | installation).   
    20.     It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This   
    21.     location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml   
    22.     | | The sections in this sample file are intended to give you a running start   
    23.     at | getting the most out of your Maven installation. Where appropriate,   
    24.     the default | values (values used when the setting is not specified) are   
    25.     provided. | | -->  
    26. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"  
    27.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    28.     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
    29.     <!-- localRepository | The path to the local repository maven will use to   
    30.         store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> -->  
    31.   
    32.     <!-- interactiveMode | This will determine whether maven prompts you when   
    33.         it needs input. If set to false, | maven will use a sensible default value,   
    34.         perhaps based on some other setting, for | the parameter in question. | |   
    35.         Default: true <interactiveMode>true</interactiveMode> -->  
    36.   
    37.     <!-- offline | Determines whether maven should attempt to connect to the   
    38.         network when executing a build. | This will have an effect on artifact downloads,   
    39.         artifact deployment, and others. | | Default: false <offline>false</offline> -->  
    40.   
    41.     <!-- pluginGroups | This is a list of additional group identifiers that   
    42.         will be searched when resolving plugins by their prefix, i.e. | when invoking   
    43.         a command line like "mvn prefix:goal". Maven will automatically add the group   
    44.         identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these   
    45.         are not already contained in the list. | -->  
    46.     <pluginGroups>  
    47.         <!-- pluginGroup | Specifies a further group identifier to use for plugin   
    48.             lookup. <pluginGroup>com.your.plugins</pluginGroup> -->  
    49.     </pluginGroups>  
    50.   
    51.     <!-- proxies | This is a list of proxies which can be used on this machine   
    52.         to connect to the network. | Unless otherwise specified (by system property   
    53.         or command-line switch), the first proxy | specification in this list marked   
    54.         as active will be used. | -->  
    55.     <proxies>  
    56.         <!-- proxy | Specification for one proxy, to be used in connecting to the   
    57.             network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol>   
    58.             <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host>   
    59.             <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> -->  
    60.     </proxies>  
    61.   
    62.     <!-- servers | This is a list of authentication profiles, keyed by the server-id   
    63.         used within the system. | Authentication profiles can be used whenever maven   
    64.         must make a connection to a remote server. | -->  
    65.     <servers>  
    66.         <!-- server | Specifies the authentication information to use when connecting   
    67.             to a particular server, identified by | a unique name within the system (referred   
    68.             to by the 'id' attribute below). | | NOTE: You should either specify username/password   
    69.             OR privateKey/passphrase, since these pairings are | used together. | <server>   
    70.             <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password>   
    71.             </server> -->  
    72.   
    73.         <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id>   
    74.             <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave   
    75.             empty if not used.</passphrase> </server> -->  
    76.     </servers>  
    77.   
    78.     <!-- mirrors | This is a list of mirrors to be used in downloading artifacts   
    79.         from remote repositories. | | It works like this: a POM may declare a repository   
    80.         to use in resolving certain artifacts. | However, this repository may have   
    81.         problems with heavy traffic at times, so people have mirrored | it to several   
    82.         places. | | That repository definition will have a unique id, so we can create   
    83.         a mirror reference for that | repository, to be used as an alternate download   
    84.         site. The mirror site will be the preferred | server for that repository.   
    85.         | -->  
    86.     <mirrors>  
    87.         <!-- mirror | Specifies a repository mirror site to use instead of a given   
    88.             repository. The repository that | this mirror serves has an ID that matches   
    89.             the mirrorOf element of this mirror. IDs are used | for inheritance and direct   
    90.             lookup purposes, and must be unique across the set of mirrors. | <mirror>   
    91.             <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable   
    92.             Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url>   
    93.             </mirror> -->  
    94.   
    95.   
    96.   
    97.         <mirror>  
    98.             <id>maven.mirrorid</id>  
    99.             <mirrorOf>central</mirrorOf>  
    100.             <name>Human Readable Name for this Mirror.</name>  
    101.             <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>  
    102.         </mirror>  
    103.         <mirror>  
    104.             <id>mirrorId</id>  
    105.             <mirrorOf>*</mirrorOf>  
    106.             <name>Human Readable Name for this Mirror.</name>  
    107.             <url>http://maven.mirrorid/content/groups/public/</url>  
    108.         </mirror>  
    109.     </mirrors>  
    110.   
    111.     <!-- profiles | This is a list of profiles which can be activated in a variety   
    112.         of ways, and which can modify | the build process. Profiles provided in the   
    113.         settings.xml are intended to provide local machine- | specific paths and   
    114.         repository locations which allow the build to work in the local environment.   
    115.         | | For example, if you have an integration testing plugin - like cactus   
    116.         - that needs to know where | your Tomcat instance is installed, you can provide   
    117.         a variable here such that the variable is | dereferenced during the build   
    118.         process to configure the cactus plugin. | | As noted above, profiles can   
    119.         be activated in a variety of ways. One way - the activeProfiles | section   
    120.         of this document (settings.xml) - will be discussed later. Another way essentially   
    121.         | relies on the detection of a system property, either matching a particular   
    122.         value for the property, | or merely testing its existence. Profiles can also   
    123.         be activated by JDK version prefix, where a | value of '1.4' might activate   
    124.         a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally,   
    125.         the list of active profiles can be specified directly from the command line.   
    126.         | | NOTE: For profiles defined in the settings.xml, you are restricted to   
    127.         specifying only artifact | repositories, plugin repositories, and free-form   
    128.         properties to be used as configuration | variables for plugins in the POM.   
    129.         | | -->  
    130.     <profiles>  
    131.         <!-- profile | Specifies a set of introductions to the build process, to   
    132.             be activated using one or more of the | mechanisms described above. For inheritance   
    133.             purposes, and to activate profiles via <activatedProfiles/> | or the command   
    134.             line, profiles have to have an ID that is unique. | | An encouraged best   
    135.             practice for profile identification is to use a consistent naming convention   
    136.             | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey',   
    137.             'user-brett', etc. | This will make it more intuitive to understand what   
    138.             the set of introduced profiles is attempting | to accomplish, particularly   
    139.             when you only have a list of profile id's for debug. | | This profile example   
    140.             uses the JDK version to trigger activation, and provides a JDK-specific repo.   
    141.             <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories>   
    142.             <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url>   
    143.             <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository>   
    144.             </repositories> </profile> -->  
    145.   
    146.         <!-- | Here is another profile, activated by the system property 'target-env'   
    147.             with a value of 'dev', | which provides a specific path to the Tomcat instance.   
    148.             To use this, your plugin configuration | might hypothetically look like:   
    149.             | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId>   
    150.             | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration>   
    151.             | </plugin> | ... | | NOTE: If you just wanted to inject this configuration   
    152.             whenever someone set 'target-env' to | anything, you could just leave off   
    153.             the <value/> inside the activation-property. | <profile> <id>env-dev</id>   
    154.             <activation> <property> <name>target-env</name> <value>dev</value> </property>   
    155.             </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath>   
    156.             </properties> </profile> -->  
    157.     </profiles>  
    158.   
    159.     <!-- activeProfiles | List of profiles that are active for all builds. |   
    160.         <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile>   
    161.         </activeProfiles> -->  
    162. </settings>  


  3. 删除C:\Users\Administrator\.m2\repository目录下所有后缀名是.lastUpdated的文件
  4. 进入eclipse,右键项目,运行maven ->Update Dependences
  5. 等下载完所有的jar之后,如果项目还有错误,就右键项目,运行Maven->update project configuration
0 0
原创粉丝点击