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安装及验证 按提示完成安装,安装 ...
随机推荐
- opencv人脸检测分类器训练小结
这两天在初学目标检测的算法及步骤,其中人脸检测作为最经典的算法,于是进行了重点研究.该算法最重要的是建立人脸检测分类器,因此我用了一天的时间来学习分类器的训练.这方面的资料很多,但是能按照一个资料运行 ...
- [LeetCode] Container With Most Water 简要分析
前言 这题非要说贪心的话也算是吧,不过最主要的特征还是双指针.LC的题好像不少都是扔倆头尾指针然后遍历一遍完事儿的.这道题倒是“短板效应”的不错体现了. 题目 题目链接 Given n non-neg ...
- Chapter4:表达式
左值和右值 当一个对象被用作右值的时候,用的是对象的值(内容),当对象被用作左值的时候,用的是对象的身份(在内存中的位置). 一个重要的原则是需要右值的地方可以用左值来代替,但是不能把右值当作左值使用 ...
- Python面向对象1
一.类和对向 面向过程和面向对象的编程 面向过程的编程:函数式编程,C程序等 面向对象的编程:C++,JAVA,Python等 类和对象:是面向对象中的2个重要概念 类:是事物的抽象,比如汽车: 对象 ...
- JavaEE5 Tutorial_Servlet
Web资源:web组件,静态web文件如图片 Web程序:可发布的Web资源集合 Web程序根目录下有个web-inf文件夹,如果只有jsp和静态资源,里面可以没有web.xml 根目录下可以直接 ...
- CORBA
公共对象请求代理体系结构(Common Object Request Broker Architecture)
- 如何使用git创建远程仓库(供局域网多人使用)
用git init(默认创建的是私人的仓库)创建的仓库,推送是不会成功的. 因此在git server端,我们要用 git --bare init --shared=group 来创建一个bare库, ...
- 转】Apache解决高并发和高可用
原博主于: http://www.ha97.com/5803.html 感谢! 服务器集群 Apache 和 nginx(web服务器) 1. 多台集群机器联合处理一个任务. 2. 一台机器处 ...
- 【转】Maven实战(五)---两个war包的调用
原博文出自于: http://blog.csdn.net/liutengteng130/article/details/42879803 感谢! 开篇前提 1.为什么要用两个war包的调用? ...
- oracle 监测数据库是否存在指定字段
public static bool ExistColumn(string tableName, string columnName, string connStr) { using (OracleC ...