如何使用 SBT 导入 Maven 依赖项 [英] how to import a Maven dependency using SBT

查看:68
本文介绍了如何使用 SBT 导入 Maven 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 scala/play 项目中获得 embedded-cassandra,该项目使用 sbt 而不是 maven.(https://github.com/nosan/embedded-cassandra/wiki)

I am trying to get embedded-cassandra in my scala/play project which uses sbt instead of maven. (https://github.com/nosan/embedded-cassandra/wiki)

我将以下 maven 依赖翻译成 sbt.

I translated the following maven dependency into sbt.

<!-- Core API -->
     <dependency>
          <groupId>com.github.nosan</groupId>
          <artifactId>embedded-cassandra</artifactId>
          <version>2.0.1</version>
    </dependency>

    <!-- Test Extensions (Spring, JUnit, etc.) -->
     <dependency>
         <groupId>com.github.nosan</groupId>
         <artifactId>embedded-cassandra-test</artifactId>
         <version>2.0.1</version>
         <scope>test</scope>
     </dependency>

SBT 转换

"com.github.nosan"%"embedded-cassandra" % "2.0.1" % "test"

但是当我尝试在单元测试中导入嵌入式 cassandra 时出现编译错误.

But I am getting compilation error when I try to import embedded-cassandra in my unit test.

import com.github.nosan.embedded.cassandra.Cassandra

错误

Error:(7, 12) object github is not a member of package com
import com.github.nosan.embedded.cassandra.Cassandra

我做错了什么?

推荐答案

事实证明,问题是 SBT 没有下载依赖项.我重新导入了该项目并且一切正常.我做了另一个改变.我从 sbt 条目中删除了 % test 虽然说实话我不知道这是否有任何影响.

Turns out, the issue was that SBT hadn't downloaded the dependency. I re-imported the project and things worked. I made another change. I removed the % test from the sbt entry though to be honest I don't know if that had any implications.

这篇关于如何使用 SBT 导入 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆