Spark之路 --- Scala IDE Maven配置(使用开源中国的Maven库)和使用
为什么要使用Maven
摘自百度百科的介绍
Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。
Maven 除了以程序构建能力为特色之外,还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性,所以常常用两三行 Maven 构建脚本就可以构建简单的项目。由于 Maven 的面向项目的方法,许多 Apache Jakarta 项目发文时使用 Maven,而且公司项目采用 Maven 的比例在持续增长。
我为什么要使用Maven
作为一个Java/Scala的新人,我第一次使用Maven的时候,并不太了解Maven的什么,我所想的只是在我的Scala项目中引入一个画图表的库,后来我的Github找到了一个我想要的库。在我想引用这个库,潜意识里我就开始寻找这个库的Jar包,最后用Maven顺利解决我的项目的依赖问题。
Scala IDE Maven配置(使用开源中国的Maven库)
为什么要重新配置Maven
因为Maven默认用的是外国的库,国外的服务器在大陆访问要么是连接不上要么是连接上了乌龟那么慢,为了不折腾我脆弱的心灵还是用国内的Maven库吧。
Scala IDE Maven配置
打开Maven配置:Window->Perferences->Maven->User Settings
默认的Settings路径是:C:\Users\Administrator\.m2\Settings 当然你也可以把路径更改到你想要放的地方
我的Maven配置,参考开源中国 Maven 库使用帮助 传送门
<?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.home}/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: ~/.m2/repository --> <localRepository>E:\maven\repo</localRepository> <!-- interactiveMode | This will determine whether maven prompts you when
it needs input. If set to false, | maven will 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 will have an effect on artifact downloads,
artifact deployment, and others. |localRepository | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that
will be searched when resolving plugins by their prefix, i.e. | when invoking
a command line like "mvn prefix:goal". Maven will automatically add the group
identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these
are 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 be used on this machine
to connect to the network. | Unless otherwise specified (by system property
or command-line switch), the first proxy | specification in this list marked
as active will be used. | --> <proxies>
<!-- proxy | Specification for one proxy, to be used in connecting to the
network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol>
<username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host>
<port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> -->
</proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id
used within the system. | Authentication profiles can be used whenever maven
must make a connection to a remote server. | --> <servers>
<!-- server | Specifies the authentication information to use when 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>repopwd</password>
</server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id>
<privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave
empty if not used.</passphrase> </server> -->
</servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts
from remote repositories. | | It works like this: a POM may declare a repository
to use in resolving certain artifacts. | However, this repository may have
problems with heavy traffic at times, so people have mirrored | it to several
places. | | That repository definition will have a unique id, so we can create
a mirror reference for that | repository, to be used as an alternate download
site. The mirror site will be 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 has an ID that matches
the mirrorOf element of this mirror. IDs are used | for inheritance and direct
lookup purposes, and must be unique across the set of mirrors. | -->
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
</mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety
of ways, and which can modify | the build process. Profiles provided in the
settings.xml are 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 an integration testing plugin - like cactus
- that needs to know where | your Tomcat instance is installed, you can provide
a variable here such that 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) - will be discussed later. Another way 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
be activated by JDK version prefix, where a | value of '1.4' might activate
a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally,
the list of active profiles can be specified directly from the command line.
| | NOTE: For profiles defined in the settings.xml, you are 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>
<id>jdk1.8.0_65</id>
<activation>
<jdk>1.8.0_65</jdk>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- activeProfiles | List of profiles that are active for all builds. |
<activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles> -->
</settings>
Maven的使用(我的使用方式~哈)
查找你想要的引用的库
- 可以在Github或Google自己要用到的库
- 然后在官方库或开源的Maven库查找你所要的库 官方:传送门 开源中国:传送门(建议使用官方库搜索)
- 把搜索结果里的Maven依赖XML内容添加到你的pom文件的依赖标签里
搜索的时候的注意事项
- 要对比好你要引用库的所属组和构件,因为搜索结果可能什么很多
- 还要要把你引用的库的依赖的库也一起添加到你的pom文件的依赖(我一直觉得这一步是可以自动做到的,只是我还没有学会而已)
官方搜索结果
从搜索可以看到官方的库支持很多的构建工具:Maven/Ivy/SBT
在官方的搜索结果中还会列出所搜索库的依赖库,只要点击相应的链接就可以跳转到依赖库,使用起来很方便,不用多次查找。
开源中国搜索结果
pom文件依赖配置
Spark之路 --- Scala IDE Maven配置(使用开源中国的Maven库)和使用的更多相关文章
- Maven 项目使用开源中国镜像
从maven中央库下载jar非常缓慢甚至有时候会下载不下来. 可以采用中国的maven镜像.目前主要是 开源中国的镜像. 找到maven配置文件setting.xml,打开 中间添加开源中国的配置: ...
- virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区
virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区 virtenv 0.8.6 发布,virtenv 是一个用 QT4 开发的应用,用来配置和启动基于 LXC 的虚拟桌面环境.该容器 ...
- Spark之路 --- Scala用JFreeChart画图表实例
JFreeChart介绍 JFreeChart是JAVA平台上的一个开放的图表绘制类库.它完全使用JAVA语言编写,是为applications, applets, servlets 以及JSP等使用 ...
- maven配置之:<distributionManagement>snapshot快照库和release发布库
在使用maven过程中,我们在开发阶段经常性的会有很多公共库处于不稳定状态,随时需要修改并发布,可能一天就要发布一次,遇到bug时,甚至一天要发布N次.我们知道,maven的依赖管理是基于版本管理的, ...
- Ubuntu下Maven配置与Maven项目创建教程
一. Ubuntu下Maven配置 windows下Maven配置参考http://www.cnblogs.com/LexMoon/p/JavaMaven.html ubuntu下Maven地址htt ...
- maven配置详解
什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者需要遵循的规则,缺陷管理系统,组织和licenses,项目的 ...
- 史上最强maven配置详情
史上最强maven配置详情 优点 对第三方依赖库进行了统一的版本管理 统一了构建过程 统一了项目的目录结构 构建 清理 : mvn clear 编译 : mvn compile 测试 : mvn te ...
- 【maven】在idea上创建maven多模块项目
参考:https://www.cnblogs.com/wangmingshun/p/6383576.html 一:创建父项目 (1)idea引导页 (2)创建父项目,不需要选择maven插件 (3)完 ...
- Spark之路 --- Windows Scala 开发环境安装配置
JDK安装 JDK安装包下载 到Oracle官网下载JDK. 传送门 下载之前要记得勾选上同意协议然后选择相应的版本(Windows/Linux, 32/64) JDK安装及验证 按提示完成安装,安装 ...
随机推荐
- qt集成到vs2010
因为要正式开始学习图形处理相关的知识了,所以要搭建开发平台.我所要用到的平台主要是vs和qt.虽然现在已经出了vs2013了,并且外观看起来特别漂亮,但是我所要用到的qt4版本中,没有对于的qtAdd ...
- redo buffer大小
转载自http://blog.csdn.net/robinson1988/article/details/4729858 log buffer 是SGA中一块循环使用的内存区域,它一般很小,因为有4个 ...
- RPC框架motan: 通信框架netty之Netty4Client
上文已经初步探讨了如何实现一个具体的transport,本文就来讨论一个具体的transport,本文讨论netty4的的相关实现.老规矩,看看motan-transport的目录结构. 其中最重要的 ...
- 【Hadoop代码笔记】Hadoop作业提交之JobTracker接收作业提交
一.概要描述 在上一篇博文中主要描述了JobTracker接收作业的几个服务(或功能)模块的初始化过程.本节将介绍这些服务(或功能)是如何接收到提交的job.本来作业的初始化也可以在本节内描述,但是涉 ...
- 第二百六十天 how can I 坚持
晚上去看了个电影,<万万没想到>,挺好看的,豆瓣评分不高.网络啊. 互联网会让聪明的人越来越聪明. 明天去看寻龙诀了. 懒惰会生根发芽,哈哈. 睡觉了.
- SSH原理与运用一:远程登录(转)
原文:http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html 作者: 阮一峰 SSH是每一台Linux电脑的标准配置. 随着Linux ...
- struts2+Hibernate4+spring3+EasyUI环境搭建之五:引入jquery easyui
1.下载jquery easyui组件 http://www.jeasyui.com/download/index.php 2.解压 放到工程中 如图 3.jsp引入组件:必须按照如下顺序 ...
- POJ 1308 Is It A Tree? (并查集)
Is It A Tree? 题目链接: http://acm.hust.edu.cn/vjudge/contest/123393#problem/M Description A tree is a w ...
- iOS学习之基本概念
学习iOS最重要的是态度和兴趣,如果你对于学习始终抱有不断的热情和端正的态度,那么,无论是什么,你总会成功的! 有一句话与大家共勉:过程中跌倒多少次都没有关系,重要的是,跌倒后你能够站起来重新寻找正确 ...
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...