Eclipse下新建Maven项目、自动打依赖jar包

时间:2022-08-28 19:19:54

Eclipse下新建Maven项目、自动打依赖jar包

  当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库。一般地,对于每个人来说,书房只有一个,但外面的书店有很多,类似第,对于Maven来说,每个用户只有一个本地仓库,但可以配置访问很多远程仓库。

Eclipse *版本

Eclipse *下载

强烈推荐书籍:Maven实战   许晓斌著。目前是第一版

注意:最新版本的Eclipse代号Mars,已经直接集成了Maven,所以无需安装m2Eclipse插件。

Eclipse下新建Maven项目

1、下载Maven安装包

进入Maven官网的下载页面:http://maven.apache.org/download.cgi,如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

选择当前最新版本:"apache-maven-3.3.9-bin.zip",下载到本地,解压缩到本地磁盘下。

Eclipse下新建Maven项目、自动打依赖jar包

2、配置

2.1 环境变量的配置

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

2.2 修改默认的本地仓库位置

  进入Maven安装目录下的conf子目录中,打开settings.xml进行配置修改。

  Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->

<localRepository>D:/SoftWare/maven/repository</localRepository>

  Maven默认的本地仓库位置是当前用户工作目录下的".m2/repository",使用过程中这个目录里的文件会比较多,占用空间越来越大。一般建议更换到其它磁盘目录下。如下配置,就把默认的本地仓库更改到自己创建的目录。

  如下图所示的localRepository标签中设置,就把默认的本地仓库更改到D:/SoftWare/maven/repository这个目录(这个目录结构需要自己创建好)。

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

2.3修改默认的*仓库镜像

  Maven默认的*仓库里的文件不全。所以,都需要自行添加其它的镜像地址。在settings.xml文件中的“<mirrors>”标签里添加如下内容:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

其实,是如下   http://mirrors.ibiblio.org/maven2/

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

 注意啦!有时候,上面这样配置,不稳定,我这里给大家分享一个稳定的setting.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.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: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->

<localRepository>D:/SoftWare/maven/repository</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.
|
| 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>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>osc</id>
<mirrorOf>central</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/repositories/central</url>
</mirror>

<mirror>
<id>osc_thirdparty</id>
<mirrorOf>thirdparty</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/repositories/central</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
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>

<activation>
<jdk>1.4</jdk>
</activation>

<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->

<!--
| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
| might hypothetically look like:
|
| ...
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
| ...
|
| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
| anything, you could just leave off the <value/> inside the activation-property.
|
<profile>
<id>env-dev</id>

<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>

<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>

<repositories>

<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central</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.aliyun.com/nexus/content/repositories/central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>

</pluginRepositories>
</profile>

<profile>
<id>osc</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<repositories>

<repository>
<id>osc</id>
<url>http://maven.aliyun.com/nexus/content/repositories/central</url>
</repository>

<repository>
<id>osc_thirdparty</id>
<url>http://maven.aliyun.com/nexus/content/repositories/central</url>
</repository>

</repositories>

<pluginRepositories>

<pluginRepository>
<id>osc</id>
<url>http://maven.aliyun.com/nexus/content/repositories/central</url>
</pluginRepository>

</pluginRepositories>
</profile>
</profiles>

<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>

保存所做的修改,同时还需要把这个settings.xml文件复制一份到“D:\SoftWare\maven”目录下。

Eclipse下新建Maven项目、自动打依赖jar包

3、eclipse里的Maven插件安装

  Eclipse默认不支持Maven。需要给它添加m2eclipse插件。下面是具体的操作步骤。

3.1、插件安装

  打开Eclipse的Help->Install New Software,如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

选择“Add..”按钮,又会弹出如下对话框:

Eclipse下新建Maven项目、自动打依赖jar包

这个对话框就是用于添加一个插件地址的。在“Name”对应的输入框里输入该操作的一个标识名。在“Location”对应的输入框里输入这个插件的安装地址。注:Maven的Eclipse插件地址为:http://download.eclipse.org/technology/m2e/releases。输入后,如下图所示:

Name:  m2e

Location:  http://download.eclipse.org/technology/m2e/releases

Eclipse下新建Maven项目、自动打依赖jar包

输入完成后,点击右下角的“OK”按钮,就会弹出如下对话框:

Eclipse下新建Maven项目、自动打依赖jar包

MARS版本

Eclipse下新建Maven项目、自动打依赖jar包

我这里,就,已经安装过了。

这一步,有可能会

注意:安装maven时一定要注意版本匹配问题:下面就是我安装时遇到的问题

首先安装maven时遇到Missing requirement: m2e logback configuration 1.7.0.20160603-1933 (org.eclipse.m2e.logback.configur。。。的问题。

这是由于eclipse和maven插件版本不匹配,我的eclipse版本为如下,只能安装m2e - http://download.eclipse.org/technology/m2e/releases/1.3的版本,高版本就报错

Eclipse下新建Maven项目、自动打依赖jar包

推荐用MARS版本!!!

Eclipse下新建Maven项目、自动打依赖jar包

注意,有些版本,我已测试过,如,NEON版本

Eclipse下新建Maven项目、自动打依赖jar包

会发生上述的错误。

这里需要选择想要安装的插件的详细内容。选中“Maven Integration for Eclipse”前面的复选框。如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

选择完成后,点击右下方的“Next>”按钮进行安装。安装成功后,会提示需要重启Eclipse来生效这次配置。重启之后,这个Eclipse就可以使用m2eclipse插件功能了。

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

需要一段时间

Eclipse下新建Maven项目、自动打依赖jar包

自动重启

3.2、Eclipse下对maven进行配置

  插件安装好之后,还需要进行一些配置才能够开始使用Maven的功能。

3.2.1、 设置m2eclipse插件所关联的Maven程序

  需要修改配置:首先选择Window->Preferences,弹出如下对话框

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

在这个对话框左边的导航栏中展开“Maven”目录结点,并选择“Installations”子节点,如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

这里需要关联上对应的Maven安装程序。具体操作是,在右边面板中选择“Add…”按钮,会弹出如下选择Maven安装目录的选择对话框:

通过这个对话框来选择Maven的具体安装目录。选择好之后就点击“确定”按钮。如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

3.2.2、 设置自定义的本地仓库

  选择如上图对话窗口左边菜单树 “Maven”节点下的“UserSettings”子节点,它默认的配置文件是“C:\Documents and Settings\csdn\.m2\settings.xml”,如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

这边需要修改为我们自定义仓库位置下的settings.xml文件。具体操作是,点击“Browse…”按钮来选择上一步骤修改的本地仓库目录下的settings.xml文件,如下图所示:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

在上图中选择D:\SoftWare\apache-maven-3.3.9\conf目录下的“settings.xml”文件,点击“打开”按钮来确认刚才的选择,就会回到如下图的对话窗口中:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

在上图中点击右下角的“OK”按钮来完成所有的配置修改。

4、Eclipse创建maven项目

在eclipse菜单栏中选择"File"->"News"->"Other"菜单项,就会打开如下对话窗口,在窗口中选择"Maven"节点下"Maven Project"条目,如下图所示,之后跟着下一步。。。就可以将项目创建好了。

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

我这里,选择other

Eclipse下新建Maven项目、自动打依赖jar包

想说的是,SBT是为scala专门而设计的,但是,一般很多人还是用的是maven。

Eclipse下新建Maven项目、自动打依赖jar包

使用maven-archetype-quickstart 或者 coccoon-22-archetype-webapp

Eclipse下新建Maven项目、自动打依赖jar包

或者

Eclipse下新建Maven项目、自动打依赖jar包

也许,这一步,会碰到如下问题。

Eclipse下新建Maven项目、自动打依赖jar包

解决办法:

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

或者

Catalog File: http://repo2.maven.org/maven2/archetype-catalog.xml

Description: maven catalog

Eclipse下新建Maven项目、自动打依赖jar包

然后,再重新 File  ->   New   ->   Maven Project

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

这里,自己任意取,

Group Id:  com.zhouls.spark

Artifact Id:  SparkApps

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

 CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: UnresolvableModelException: Failure to transfer org.apache.maven.plugins:maven-plugins:pom:24 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-plugins:pom:24 from/to central (https://repo.maven.apache.org/maven2): timeout

解决方法:

1.找到maven库目录,进入:D:\SoftWare\maven\repository\org\apache\maven\plugins\maven-compiler-plugin\3.1

Eclipse下新建Maven项目、自动打依赖jar包

2. 若3.1这个目录下只有,"maven-compiler-plugin-3.1.pom.lastUpdated" 则需要到http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/,把里面的文件下载下来放到目录3.1下,如果该仓库中没有,那么可以去http://search.maven.org/这个地方下载下来,然后放置到对应的本地仓库中

Eclipse下新建Maven项目、自动打依赖jar包

可见,我这里是不需进行步骤2,直接到步骤3.

3.删除3.1下的maven-compiler-plugin-3.1.pom.lastUpdated文件或3.1目录下的所有文件

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

4.项目右键-->maven-->Update Dependencies

即,得到解决!

如果以上方法还是无法解决该问题:则 打开settings.xml,尝试换个mirror镜像或者干脆采用默认的仓库,即注释掉

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

删除清空

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

再重新来一次

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

这里,我继续,上面的步骤,下来。用了我那个稳定的setting.xml文件,之后,中间不会出现什么问题!!!

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

把此处默认的jdk,J2SE-1.5,变成我们自己安装的jdk版本(jdk1.7或jdk1.8)

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

得到

Eclipse下新建Maven项目、自动打依赖jar包

对应,得到

Eclipse下新建Maven项目、自动打依赖jar包

这个pom.xml文件,里有我们工程实际时编写和运行时的依赖和支持。

进入,如下

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

选择,pom.xml

Eclipse下新建Maven项目、自动打依赖jar包

在修改pom.xml文件之前,Maven Dependencies如下

Eclipse下新建Maven项目、自动打依赖jar包

创建项目之后,pom.xml默认的内容如下

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.zhouls.spark</groupId>
<artifactId>SparkApps</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SparkApps</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Eclipse下新建Maven项目、自动打依赖jar包

这一步,最为关键,具体怎么修改pom.xml,是要看自己的需求。

http://mvnrepository.com/

Eclipse下新建Maven项目、自动打依赖jar包

我这里,因为是spark1.5.2版本。

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

其他的,类似,这里不多赘述。

转】maven核心,pom.xml详解

这过程中,最好是去复制,官网。为了避免自己手误或者格式不对!!!可以避免如下面的错误!

修改后的pom.xml内容是

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.zhouls.spark</groupId>
<artifactId>SparkApps</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SparkApps</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.10</junit.version>
<spark.version>1.5.2</spark.version>
<hadoop.version>2.6.0</hadoop.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.10</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka_2.10</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/main/test</testSourceDirectory>

<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<classpathScope>compile</classpathScope>
<mainClass>com.zhouls.spark.SparkApps.cores.WordCount</mainClass>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

</plugins>
</build>
</project>

Eclipse下新建Maven项目、自动打依赖jar包

正在下载

Eclipse下新建Maven项目、自动打依赖jar包

立马生成好了。可见,Maven自动生成jar包,多么的方便!

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包

其他的一一去解决!

对应地,生成,

Eclipse下新建Maven项目、自动打依赖jar包

我的这里,得到如下

Eclipse下新建Maven项目、自动打依赖jar包

至此,Eclipse下新建Maven项目、自动打依赖jar包。大功告成!!!

 Eclipse里创建Maven,比较有价值的错误总结

http://blog.csdn.net/afgasdg/article/details/12757433

http://blog.csdn.net/sunnylinner/article/details/52183156

http://www.cnblogs.com/liaojie970/p/5509760.html

http://www.cnblogs.com/tenghoo/p/maven_error.html

  感谢如下博主:

http://www.cnblogs.com/ljdblog/p/5840858.html

http://blog.csdn.net/qjyong/article/details/9098213

http://dead-knight.iteye.com/blog/1910783

关于Maven的进一步,深入学习,推荐

Eclipse下新建Maven项目、自动打依赖jar包

Eclipse下新建Maven项目、自动打依赖jar包的更多相关文章

  1. eclipse下新建maven项目

    eclipse下新建maven项目 1.1下载maven安装包 进入Maven官网的下载页面:http://maven.apache.org/download.cgi,如下图所示:\ 选择当前最新版本 ...

  2. Eclipse下Maven新建项目、自动打依赖jar包(包含普通项目和Web项目)

    不多说,直接上干货! 当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库.一般地,对于每个人来说,书房只有一个,但外面的书店有很多,类似第,对于Maven来说,每个用户只有一个 ...

  3. &lbrack;Eclipse的Maven项目搭建,仅为测试Maven功能&rsqb;如何在Eclipse下搭建Maven项目

    [Eclipse的Maven项目搭建,仅为测试Maven功能]如何在Eclipse下搭建Maven项目   你可能需要了解以下才能更好的阅读以下: 在 Windows 中配置Maven: http:/ ...

  4. Java web项目搭建系列之一 Eclipse中新建Maven项目

    前提条件: 已经安装好JDK 已经安装好Maven 已经安装好Eclipse 已经安装好Maven插件 在Eclipse中新建Maven项目 [File]→[New]→[Other...] [Mave ...

  5. eclipse下将maven项目打包为jar&lpar;1&period;不带第三方jar,2&period;带第三方jar&rpar;

    由于项目需要讲maven项目打包为jar包,由于之前没类似经验,百度找例子走了不少弯路,这边随手记录下,网上说的 开发工具:eclipse jar包管理:maven 一般打包出来的jar包分为两种 一 ...

  6. Eclipse下运行maven项目失败且Tomcat服务器也启动不了

    今天遇到一个神奇的问题,在eclipse中创建一个maven项目后,Run on server 时说服务器启动失败.我以为是Eclipse配置tomcat的问题.找了一大堆没找到想要的答案!!! 我还 ...

  7. 5&period;Maven和Eclipse整合(两种方式进行插件的安装),Maven相关设置,Eclipse下创建Maven项目

     1  第一种方式是:在连网的情况下.通过在helpàInstall下安装. 新的地址是:http://download.eclipse.org/technology/m2e/releases 2 ...

  8. eclipse上新建Maven项目报错及解决

    Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of ...

  9. eclipse下创建maven项目并部署到tomcat服务器&lpar;转&rpar;

    maven项目部署到服务器有很多方法,可以利用jetty-maven-plugin或者tomcat-maven-plugin,这属于maven的知识点. 通常开发中,需要将项目放在服务器上借助开发工具 ...

随机推荐

  1. What&&num;39&semi;s Security

    研究安全应该时常问自己这个问题,什么是安全,什么是安全,什么是安全,安全的本质是什么,只有理解了安全的本质,才能成功的设计一个安全方案. 现在的感觉是没有绝对的安全,所谓的'安全'其实都只不过是增加攻 ...

  2. JavaScript - call&lpar;this&rpar;

    为什么使用call(this), 而不是直接使用(function(){})(); "use strict" function Foo() { (function() { cons ...

  3. 【Linux】多睡&sol;少睡一小时!冬夏令时全解析

    多伦多2016年11月6日凌晨2点开始起时间调回一小时,时间到凌晨2点时自动跳回到1点,大家可以多睡一小时(或者多一小时写essay的时间)~ 多伦多2017年3月12日凌晨2点开始时间拨快一小时时间 ...

  4. html 中的name,id ,value,class,list 作用与区别

    name: 单独一个网页中,一个控件是否设置name不会影响这个网页功能的实现.当我们需要把这个控件 所关联的数据传递到数据库时,就必须设置name属性,否则这个值是没办法传到服务器保存的: id: ...

  5. Linux中的IO复用接口简介(文件监视?)

    I/O复用是Linux中的I/O模型之一.所谓I/O复用,指的是进程预先告诉内核,使得内核一旦发现进程指定的一个或多个I/O条件就绪,就通知进程进行处理,从而不会在单个I/O上导致阻塞. 在Linux ...

  6. 微软为&period;NET程序员带来了最优的跨平台开发体验-WSL

    前言 在前几个Visual Studio Code更新中发现有一个重要得特性,就是nodejs可以使用VS Code在WSL中进行Debug了(WSL是指Win10中的Linux子系统),之前写过一篇 ...

  7. java编写之jpg图片与base64编码之间的转换

    /** * @author zyq * 将网络图片进行Base64位编码 * @param imgUrl * */ public static String encodeWebImageToBase6 ...

  8. 20155219付颖卓《网络对抗》EXP7网络欺诈技术防范

    实验后回答问题 1.通常在什么场景下容易受到DNS spoof攻击 在公共共享网络里,并且同一网段可以ping通的网络非常容易被攻击. 2.在日常生活工作中如何防范以上两攻击方法 不在不信任的公开网络 ...

  9. 再次理解 C&num; LINQ

    语言集成查询 (LINQ) 是一系列直接将查询功能集成到 C# 语言的技术统称. 查询表达式(生成表达式) 1.IEnumerable<T> 查询编译为委托.如 source.Where( ...

  10. HDU 4549

    水题: 费马小定理+快速幂+矩阵快速幂 (第一次用到费马小定理) #include<bits/stdc++.h> using namespace std; typedef long lon ...