PS:网上相关配置很多,这里仅做自己的一个配置在线备份,所以比较简略。
1. Maven 配置下载源码 和 JavaDoc
开发中,经常需要查看某个不太熟悉的类的源码,甚至是该类的 DOC 文档,在 maven 的配置文件(setting.xml)中,加入以下配置,便可以在 IDE 工具中下载选定类的源码。
<activeProfiles>
<activeProfile>downloadSources</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
2. 配置国内源【阿里】
官方的默认的源在国外,下载起来太慢,而且一旦有时候下载中断,则很可能要去手动删除中断的包,这样才不会后续出错。所以直接可以把源更换为国内源。
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
3. 配置本地路径
这里配置的是本地仓库路径,默认情况下你不配置是在用户目录下 ~/.m2/repository 中,由于我为了保证 Linux 和 windows 共用本地仓库,所以这里我把 localRepository 放在了 window 磁盘---“开发工具”,并在 Linux 启动时自动挂载。
<localRepository>/media/fknight/开发工具/maven/maven-repository</localRepository>
4. 下面是一个我配置好的 setting.xml 文件
用户只需修改本地仓库路径为你自己的实际路径(参考3)就好。
<?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