如何设置 sbt,以便它在在线时获取所有必要的依赖项,然后让我离线工作?

2023-11-25

我尝试在没有互联网连接的区域中处理我的项目。令我惊讶的是,sbt 在这种情况下遇到了麻烦。虽然,我应该将我的库放在缓存中(假设我最初在线启动该项目),但 sbt 无法解决某些依赖关系。

Sbt 无法获取我的本地 Maven 存储库,他也无法找到我认为他已经下载的其他依赖项(即在缓存中)。

*

我的问题是:如何确保当我建立连接时,sbt 一次获取缓存中的库,这样当我没有它时,它 获取我所有的本地存储库,包括 Maven 的存储库。

我问这个问题是因为据我对当前情况的了解(即没有可用的互联网连接时):

  1. sbt 从 Maven 缓存下载时遇到问题
  2. sbt可以在ivy local找到我的大部分依赖
  3. sbt 无法找到某些特定的依赖关系,由于某些原因, 显然没有被缓存。

例如,这里是 sbt 应该已经缓存的库的踪迹。

[warn]   file:///Users/maatary/.m2/repository/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom
[info] Resolving com.google.inject.extensions#guice-multibindings;4.0-beta4 ...
**[warn] Host repo1.maven.org not found.** url=http://repo1.maven.org/maven2/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
**[info] You probably access the destination server through a proxy server that is not well configured.**
[warn]  module not found: com.google.inject.extensions#guice-multibindings;4.0-beta4
**[warn] ==== local: tried
[warn]   /Users/maatary/.ivy2/local/com.google.inject.extensions/guice-multibindings/4.0-beta4/ivys/ivy.xml**
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
[warn] ==== Local Maven Repository: tried
[warn]   file:///Users/maatary/.m2/repository/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
[info] Resolving jline#jline;2.12 ...                                          
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.google.inject.extensions#guice-assistedinject;4.0-beta4: not found
[warn]  :: com.google.inject.extensions#guice-multibindings;4.0-beta4: not found

这是缓存内容:

/Users/maatary/.ivy2/cache/com.google.inject.extensions

扩展父 guice 辅助注入 guice 多重绑定

每个文件夹中都有:

ivy-4.0-beta4.xml ivydata-4.0-beta4.properties ivy-4.0-beta4.xml.原始

其他最后 2 个文件夹还包含:

jars、src 和 docs 文件夹。在罐子里你会发现罐子被拿来了。

e.g.

在辅助注入的 jars 文件夹中,您有:

guice-assistanceinject-4.0-beta4.jar

其ivy.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
        <info organisation="com.google.inject.extensions"
                module="guice-assistedinject"
                revision="4.0-beta4"
                status="release"
                publication="20140320225220"
        >
                <description homepage="" />
                <m:properties__guice.with.no_aop>true</m:properties__guice.with.no_aop>
                <m:properties__gpg.skip>true</m:properties__gpg.skip>
                <m:properties__project.build.sourceEncoding>UTF-8</m:properties__project.build.sourceEncoding>
                <m:properties__guice.api.version>1.4</m:properties__guice.api.version>
                <e:sbtTransformHash>7174be3135c2a95a21c158fb6beb5a9621b5b898</e:sbtTransformHash>
                <m:properties__guice.with.jarjar>true</m:properties__guice.with.jarjar>
                <m:maven.plugins>null__maven-gpg-plugin__1.4|null__maven-gpg-plugin__1.4|null__maven-remote-resources-plugin__null|org.codehaus.mojo__animal-sniffer-maven-plugin__null|org.apache.felix__maven-bundle-plugin__null|null__mav\
en-source-plugin__null|null__maven-javadoc-plugin__null|null__maven-gpg-plugin__1.4|null__maven-gpg-plugin__1.4|null__maven-remote-resources-plugin__null|org.codehaus.mojo__animal-sniffer-maven-plugin__null|org.apache.felix__maven-bundle\
-plugin__null|null__maven-source-plugin__null|null__maven-javadoc-plugin__null</m:maven.plugins>
        </info>
        <configurations>
                <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
                <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
                <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
                <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
                <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath\
." extends="compile"/>
                <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends\
="runtime"/>
                <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repos\
itory."/>
                <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
                <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
                <conf name="optional" visibility="public" description="contains all optional dependencies"/>
        </configurations>
        <publications>
                <artifact name="guice-assistedinject" type="jar" ext="jar" conf="master"/>
        </publications>
        <dependencies>
                <dependency org="com.google.inject" name="guice" rev="4.0-beta4" force="true" conf="compile->compile(*),master(*);runtime->runtime(*);test->runtime(*),master(*)">
                        <artifact name="guice" type="jar" ext="jar" conf="compile,runtime"/>
                        <artifact name="guice" type="jar" ext="jar" conf="test" m:classifier="tests"/>
                </dependency>
                <dependency org="cglib" name="cglib" rev="3.1" force="true" conf="test->runtime(*),master(*)">
                        <exclude org="asm" module="asm" name="*" type="*" ext="*" matcher="exact"/>
                </dependency>
                <dependency org="org.ow2.asm" name="asm" rev="5.0" force="true" conf="test->runtime(*),master(*)"/>
                <dependency org="junit" name="junit" rev="4.11" force="true" conf="test->runtime(*),master(*)"/>
        </dependencies>
</ivy-module>

其属性文件如下:

#ivy cached data file for com.google.inject.extensions#guice-assistedinject;4.0-beta4                                                                                                                                                         
#Sun Aug 17 20:44:39 CEST 2014                                                                                                                                                                                                                
artifact\:guice-assistedinject\#src\#jar\#1257084071.is-local=false
artifact\:ivy\#ivy\#xml\#-1879642188.exists=true
artifact\:guice-assistedinject\#src\#jar\#1257084071.exists=true
artifact\:ivy\#ivy\#xml\#-1879642188.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom                                                                   
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.is-local=false
artifact\:guice-assistedinject\#jar\#jar\#-589994656.is-local=false
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom                                          
artifact\:guice-assistedinject\#jar\#jar\#-589994656.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.jar                                                   
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4-javadoc.jar                                          
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.exists=true
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.exists=true
artifact\:ivy\#ivy\#xml\#-1879642188.is-local=false
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.is-local=false
artifact\:guice-assistedinject\#src\#jar\#1257084071.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4-sources.jar                                           
artifact\:guice-assistedinject\#jar\#jar\#-589994656.exists=true

See 缓存和配置.

When offline := true,远程快照不会被决议更新,即使是明确请求的更新。这应该可以有效地支持在没有连接到远程存储库的情况下进行工作。赞赏以其他方式证明的可重复示例。显然,更新必须在离线之前成功运行。

此功能可能适合您,也可能不适合您,但它旨在解决您的情况。 尝试一下,如果不起作用,请在 Github 上提交问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何设置 sbt,以便它在在线时获取所有必要的依赖项,然后让我离线工作? 的相关文章

随机推荐

  • Angular 6 / NGRX 联合减速机

    我正在使用 Angular 6 w NgRX 4 我有多个想要组合的减速器 应用程序模块 ts import BrowserModule from angular platform browser import NgModule from
  • 如果父级有 ng-if,Angular ng-show 不起作用

    我有一个视图 其中父 div 上有 ng if 而某些子元素上有 ng show 当嵌套在带有 ng if 的元素下时 ng show 似乎无法正常工作 这是 Angular 的错误还是我做错了什么 看看这个笨蛋 HTML div div
  • 使 Java 属性跨类可用?

    我选择使用属性文件来自定义某些设置 我使用以下代码使属性对象在类中可用 Properties defaultProps new Properties try FileInputStream in new FileInputStream cu
  • 如果使用 jQuery 文本为“0”,如何隐藏“span”?

    我正在寻找隐藏包含 0 的跨度 我查看了其他代码并尝试对其进行调整 但无法使其正常工作 我希望它仅在内容为 0 时隐藏跨度 但是当运行下面的代码时 它也会隐藏任何包含 0 的数字 例如 10 这是我不想要的 为了更清楚一点 跨度只应在其内部
  • 在不相关的文件中“无法重新声明块范围变量”

    有一个简单的 TS 包用作 CommonJS 模块并且没有导出 TS文件被编译为同名的JS文件并用作require package option foo tsconfig json compilerOptions target es5 选项
  • 如何通过 Javascript 将图像添加到按钮?

    我正在尝试使用 Javascript 将图像添加到按钮 但我似乎无法让它工作 我已经使用 HTML5 成功添加了图像 但是 根据我的需要 我需要通过 javascript 添加图像 以下是我编写的通过 HTML 添加图像的内容
  • Javascript 可以帮我按 Enter 键吗?

    有一个网站 我想在我离开时继续按 Enter 键 是否可以做类似的事情 setInterval function have javascript press the button with a certain id 100 我想把它放在智能
  • light gbm - python API 与 Scikit-learn API

    我正在尝试应用 LightGBM 并已经完成了 Python API文档 Training API 和 Scikit learn API 有什么区别吗 我们可以使用这两个 API 来针对同一问题获得相同的结果吗 简短的回答 是的 如果您以相
  • 如何在 tomcat 中从 Filter 类方法响应 servlet 客户端时设置 http 状态代码

    我正在用 spring 编写一个 web 服务 这个问题与 spring 无关 它实现了一个 希望 restful api 据我了解 所有响应都应采用 xml 或 json 格式 在大多数情况下 这并不是什么大问题 但在一种情况下这似乎是不
  • 如何有条件地选择numpy数组中的元素

    有人可以帮助我有条件地选择 numpy 数组中的元素吗 我正在尝试返回大于阈值的元素 我目前的解决方案是 sampleArr np array 0 725 0 39 0 99 condition sampleArr gt 0 5 extra
  • 使用 openssl verify 验证证书链

    我正在使用以下组件构建自己的证书链 Root Certificate Intermediate Certificate User Certificate 根证书是自签名证书 中间证书由根证书和中间证书由用户签名 现在我想验证用户证书是否具有
  • java8 -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=16

    所以 我试图运行一些简单的代码 jdk 8 通过 jol 输出 System out println VMSupport vmDetails Integer i new Integer 23 System out println Class
  • 错误对象属性无法通过 for 循环迭代

    我经常使用for循环来迭代JavaScript对象 直到今天才发现问题 当我试图了解 Error 对象具有哪些属性时 我感到很惊讶 var e new Error testing for var key in e console log e
  • Android:如何加载 KML

    有人可以告诉我是否有一种方法可以将 kml 文件加载到 android 中的谷歌地图中 thanks 请在此处找到一个代码示例 该示例从 google 获取 kml 数据并将其绘制到地图上 如何使用kml文件在地图上绘制路径
  • “PIVOT”附近的语法不正确

    我正在运行 SQL Server 2008 R2 我正在尝试构建一个表 该表从结构如下的表中获取数据 company ded id descr 10 1 MEDINS 10 2 LIFE 10 3 PENSN 10 50 DOMREL 我需
  • 执行 java.io.File 或 FileInputStream 时如何引用 OSGi 包中包含的文件

    我正在使用 aQute Bnd 工具集创建 OSGi 捆绑包 并打包了一些依赖的 资源 文件 这包括我创建的资源目录中的 css 文件和 xsd 文件 我已将以下内容包含在捆绑包 bnd file Include Resource reso
  • 是否可以跨多个域使用 HTML5 的 PushState()?

    我有几乎不可能的问题 但我希望有人能想出一些可行的解决方案或解决方法 我有一个我使用的网站历史 js进行按需页面更改 以防止单击链接时加载整个页面 然而 我的网站有多个域 因此跨域策略不允许更改主机的完整 URL 只能更改 设置相对路径 谁
  • React NavigatorIOS 未更新 Replace() 上的标题

    我在根组件中使用 NavigatorIOS 组件 并且想要在登录屏幕和注册屏幕之间切换 navToLogin this refs nav replace title Login component LoginScene rightButto
  • CSV 换行符出现在未加引号的字段错误中

    以下代码一直有效 直到今天我从 Windows 计算机导入并收到此错误 在未加引号的字段中看到换行符 是否需要以通用换行模式打开文件 import csv class CSV def init self file None self fil
  • 如何设置 sbt,以便它在在线时获取所有必要的依赖项,然后让我离线工作?

    我尝试在没有互联网连接的区域中处理我的项目 令我惊讶的是 sbt 在这种情况下遇到了麻烦 虽然 我应该将我的库放在缓存中 假设我最初在线启动该项目 但 sbt 无法解决某些依赖关系 Sbt 无法获取我的本地 Maven 存储库 他也无法找到