MAVEN系列教材 (三)- 仓库概念,下载与配置

前言

高产似母猪,继续肝


提示:以下是本篇文章正文内容,下面案例可供参考

步骤 1 : 仓库概念

所谓的仓库就是用于存放项目需要的jar包的。
maven采用一个仓库,多个项目的方式,让多个项目共享一个仓库里的相同jar包。

步骤 2 : 仓库默认位置

打开
D:\Java\apache-maven-3.5.0\conf\settings.xml
可以看到,在52行指定了仓库的位置是${user.home}/.m2/repository
对应我的机器就是 d:/canku/repository
个人不推荐把仓库放在xml默认路径,因为重装之后就没了
切记,一定要改成自己的仓库位置并反注释它,像我这样

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

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two 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 be 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.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are 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 is not specified) are 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 will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  -->
 <localRepository>d:/canku/repository</localRepository>

步骤 3 : 使用阿里云下载路径

maven 会默认从maven官方提供的服务器下载jar包。
而官方服务器在国外,因为大家都知道的原因,网速很慢,而且容易卡断。 为了便于快速下载相关jar包,可以使用国内maven 阿里云的下载地址:使用阿里云下载路径
在这里插入图片描述

步骤4:使用现成的仓库

我目前使用的maven仓库,是在网上随便找的库。 可以直接下载并解压在
D:\canku\repository
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/dissplay1/article/details/111319938