我´我试图冻结一个spark项目的依赖关系,使其能够脱机工作(sbt无法再下载依赖关系)。这是我遵循的过程:
创建sbt项目并通过internet连接进行编译
停止internet连接
验证项目是否继续编译
复制sbt项目并删除目标文件夹
告诉build.sbt文件从/.ivy2/cache文件夹中解析依赖项
这是build.sbt:
name := "Test"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.3.0"
resolvers += Resolver.file("Frozen IVY2 Cache Dependences", file("/home/luis/.ivy2/cache")) (Resolver.ivyStylePatterns) ivys "/home/luis/.ivy2/cache/[organisation]/[module]/ivy-[revision].xml" artifacts "/home/luis/.ivy2/cache/[organisation]/[module]/[type]s/[module]-[revision].[type]"
事实上,到达这个build.sbt的过程与这里描述的过程完全相同(没有回答):
使用org.apache.hadoop/*依赖项脱机编译sbt时遇到的问题
我包含了适当的常春藤样式模式,以指向右侧的常春藤-[revision].xml文件。
当我编译时,sbt正在为每个依赖项找到指向.ivy2/cache“冻结”存储库的正确路径,但是对于这四个依赖项,我得到了与解析文件“ivy-[revision].xml.original”相关的警告和错误:
[warn] Note: Unresolved dependencies path:
[warn] org.apache.hadoop:hadoop-mapreduce-client-app:2.2.0
[warn] +- org.apache.hadoop:hadoop-client:2.2.0
[warn] +- org.apache.spark:spark-core_2.10:1.3.0 (/home/luis/Test/build.sbt#L7-8)
[warn] +- Test:Test_2.10:1.0
[warn] org.apache.hadoop:hadoop-yarn-api:2.2.0
[warn] +- org.apache.hadoop:hadoop-client:2.2.0
[warn] +- org.apache.spark:spark-core_2.10:1.3.0 (/home/luis/Test/build.sbt#L7-8)
[warn] +- Test:Test_2.10:1.0
[warn] org.apache.hadoop:hadoop-mapreduce-client-core:2.2.0
[warn] +- org.apache.hadoop:hadoop-client:2.2.0
[warn] +- org.apache.spark:spark-core_2.10:1.3.0 (/home/luis/Test/build.sbt#L7-8)
[warn] +- Test:Test_2.10:1.0
[warn] org.apache.hadoop:hadoop-mapreduce-client-jobclient:2.2.0
[warn] +- org.apache.hadoop:hadoop-client:2.2.0
[warn] +- org.apache.spark:spark-core_2.10:1.3.0 (/home/luis/Test/build.sbt#L7-8)
[warn] +- Test:Test_2.10:1.0
让我们集中于其中一个依赖项,因为所有这些依赖项的警告和错误都是相同的。让´比如说org.apache。hadoop:hadoop-mapreduce-client-app:2.2.0
解析文件“ivy-[revision].xml.original”时出现的警告示例如下:
[warn] xml parsing: ivy-2.2.0.xml.original:18:69: schema_reference.4: Failed to read schema document 'http://maven.apache.org/xsd/maven-4.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
[warn] xml parsing: ivy-2.2.0.xml.original:19:11: schema_reference.4: Failed to read schema document 'http://maven.apache.org/xsd/maven-4.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
[warn] xml parsing: ivy-2.2.0.xml.original:20:17: schema_reference.4: Failed to read schema document 'http://maven.apache.org/xsd/maven-4.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
.......
.......
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.hadoop#hadoop-mapreduce-client-app;2.2.0: java.text.ParseException: [xml parsing: ivy-2.2.0.xml.original:18:69: cvc-elt.1: Cannot find the declaration of element 'project'. in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag project in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag parent in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag artifactId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag groupId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag version in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag modelVersion in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag groupId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag artifactId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag version in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag name in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag properties in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag applink.base in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[warn] , unknown tag mr.basedir in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
导致错误:
[error] (*:update) sbt.ResolveException: unresolved dependency: org.apache.hadoop#hadoop-mapreduce-client-app;2.2.0: java.text.ParseException: [xml parsing: ivy-2.2.0.xml.original:18:69: cvc-elt.1: Cannot find the declaration of element 'project'. in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag project in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag parent in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag artifactId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag groupId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag version in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag modelVersion in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag groupId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag artifactId in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag version in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag name in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag properties in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag applink.base in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] , unknown tag mr.basedir in file:/home/luis/.ivy2/cache/org.apache.hadoop/hadoop-mapreduce-client-app/ivy-2.2.0.xml.original
[error] ]
为了澄清,ivy-2.2.0.xml.original文件的内容如下所示:
<?xml version="1.0"?>
<!--
Licensed 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. See accompanying LICENSE file.
-->
<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">
<parent>
<artifactId>hadoop-yarn</artifactId>
<groupId>org.apache.hadoop</groupId>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-api</artifactId>
<version>2.2.0</version>
<name>hadoop-yarn-api</name>
<properties>
<!-- Needed for generating FindBugs warnings using parent pom -->
<yarn.basedir>${project.parent.basedir}</yarn.basedir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-maven-plugins</artifactId>
<executions>
<execution>
<id>compile-protoc</id>
<phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
<configuration>
<protocVersion>${protobuf.version}</protocVersion>
<protocCommand>${protoc.path}</protocCommand>
<imports>
<param>${basedir}/../../../hadoop-common-project/hadoop-common/src/main/proto</param>
<param>${basedir}/src/main/proto</param>
<param>${basedir}/src/main/proto/server</param>
</imports>
<source>
<directory>${basedir}/src/main/proto</directory>
<includes>
<include>yarn_protos.proto</include>
<include>yarn_service_protos.proto</include>
<include>applicationmaster_protocol.proto</include>
<include>applicationclient_protocol.proto</include>
<include>containermanagement_protocol.proto</include>
<include>server/yarn_server_resourcemanager_service_protos.proto</include>
<include>server/resourcemanager_administration_protocol.proto</include>
</includes>
</source>
<output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
经过这么多的介绍。。。。。。这些是我的问题:
“ivy-[revision].xml.original”文件的工作是什么?谁在试图解析它。
为什么xml标记不能被识别。
我´谢谢你的帮助!
sbt版本:0.13.8
谢谢。
2条答案
按热度按时间ezykj2lf1#
我终于成功地用sbt脱机编译/打包/组装了一部分冻结的库。为了总结这个过程,我将重写上面的描述。
以下是生成问题的步骤:
在名为origin的计算机中,让我们使用scala源代码创建一个sbt项目,并使用internet连接进行编译
停止internet连接验证项目是否继续编译
复制sbt项目或复制到其他计算机(目标),而不连接internet
试着编译。它将无法工作,因为sbt将尝试在线下载依赖项,并且目标是脱机计算机。
以下是解决问题的步骤:
假设我们正在将sbt项目复制到没有internet连接的新计算机(目的地)。我们必须确保我们的目的地的sbt版本和scala版本与原始版本相同。如果sbt或scala版本不同,那么在目的地运行sbt时,sbt将尝试下载正确的版本,从而由于缺少连接而导致错误。
如果sbt和scala版本相同,则必须将以下文件夹从源位置复制到目标位置:
来源:/home/usera/.ivy2
原点:/home/usera/.sbt/boot
确保正确配置了指向sbt和scala的环境变量
使用像这样的build.sbt文件:
内部版本.sbt:
我´我不确定“provided”是否是强制的,因为joda依赖关系正在被正确读取
请注意,您可以在目的地中使用的所有依赖项必须已在源站中下载并复制到目的地。
我试图编译一个只使用spark上下文(而不是sparksql)的简单项目。因此,它应该能够使用唯一的依赖项进行编译:
librarydependencies+=“org.apache.spark”%%“spark core”%”“1.3.0”%”“提供”
但是,我们测试它不编译!!。sbt抱怨“Jackson”套餐。也许“jackson”包部署在sparksql依赖中。。。不管怎样,包括sparksql都会使项目编译/打包/组装。
最后一点意见:如果即使遵循这个过程,您也无法成功编译,那么还有一个“手动”替代方法。。。。我也成功地脱机工作,没有sbt独立编译器。。。将eclipse用于scala。在eclipse中,您可以在图形界面中手动选择依赖项,并且可以选择所有spark、hadoop、mapreduce。。。手动创建依赖项。一旦eclipse识别出这些依赖关系,它将在路径:“workspace/eclipse\u project\u name/bin”文件夹中编译类。然后您可以将它们提取并手动打包到一个jar中(可能需要一个清单,但我猜是这样的)´没有必要)。如果集群中已经运行了所有依赖项,那么可以将这个jar提交给集群。
ubby3x7f2#
我问了你在你的帖子中提到的未回答的问题,我很高兴地宣布,它已经在几天前得到了回答,建议的解决方案对我有效。
尝试更新到sbt 0.13.9-rc3(按照http://www.scala-sbt.org/release/tutorial/manual-installation.html 把jar拿到https://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.9-rc3/).
致以最诚挚的问候,
/马丁