简体   繁体   English

从SBT导入的第3方库找不到包

[英]Imported 3rd party library from SBT can't find package

I'm using Play 2.6 with Scala - but this may not be a Play issue. 我在Scala中使用Play 2.6-但这可能不是Play问题。

I've built the project using SBT, and found a lovely CSV file reader library I wanted to use in my project. 我使用SBT构建了该项目,并找到了一个我想在项目中使用的可爱的CSV文件阅读器库 So I import it into my build.sbt as follows: 所以我将其导入到build.sbt中,如下所示:

libraryDependencies ++= Seq("com.github.tototoshi" %% "scala-csv" % "1.3.4")

And do a refresh project. 并做一个刷新项目。 I go to use one of its static methods in a class of mine, and IntelliJ suggests an auto-import, which I add to the class: 我将在我的类中使用其静态方法之一,IntelliJ建议自动导入,并将其添加到该类中:

import com.github.tototoshi.csv.CSVReader

class MyClass { ... }

But when I go to compile this via localhost:9000 in the browser, I get this error: 但是当我在浏览器中通过localhost:9000进行编译时,出现以下错误:

object github is not a member of package com

I'm new to using 3rd party libraries, but how can it not find the imported library? 我是第3方库的新手,但如何找不到导入的库? It told me where to find it, so it's in there somewhere. 它告诉我在哪里可以找到它,所以它在那儿的某个地方。 Should I change anything? 我应该改变什么吗?

Thanks. 谢谢。

EDIT 编辑

It was a Play issue. 这是一个Play问题。 I was trying to run my application from the browser - from my understanding the application compiles itself when you try to load your application after making changes. 我试图从浏览器运行我的应用程序-据我了解,当您在进行更改后尝试加载应用程序时,应用程序会自行编译。

You can use RootProject to reference an external build. 您可以使用RootProject引用外部版本。 You can find details and examples here - https://github.com/harrah/xsbt/wiki/Full-Configuration#project-references . 您可以在此处找到详细信息和示例-https: //github.com/harrah/xsbt/wiki/Full-Configuration#project-references

It was a Play issue after all. 毕竟这是一个Play问题。 I think SBT needed to do a compile on its own after I took the above steps. 我认为在执行上述步骤之后,SBT需要自己进行编译。

I simply shut down the localhost server I was running from, did a sbt clean compile run and that fixed the issue. 我只是关闭了正在运行的localhost服务器,进行了sbt clean compile run ,从而解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM