在我玩2.0框架的Java項目,下面的行產生無論是在Eclipse和在SBT編譯步驟錯誤:遊戲框架:包javax.inject不存在
import javax.inject.*;
我已經添加了javax.inject
依賴關係我build.sbt文件:
libraryDependencies ++= Seq(
javaCore,
javaJdbc,
javaEbean,
javaWs,
javaFooBar,
cache,
"javax.inject" % "javax.inject" % "1",
"org.atmosphere" % "atmosphere-play" % "2.1.1"
)
和執行clean
,update
& eclipse with-source=true
瘋狂:
[myproject] $ eclipse with-source=true
[info] About to create Eclipse project files for your project(s).
[info] Compiling 3 Scala sources and 12 Java sources to ./myproject/target/scala-2.11/classes...
[error] ./myproject/app/com/elements/legacy/LegacyController.java:3: object inject is not a member of package javax
[error] import javax.inject.*;
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[info] Resolving jline#jline;2.11 ...
[error] Could not create Eclipse project files:
[error] Error evaluating task 'dependencyClasspath': error
我感覺sbt不會拋出錯誤,以防無法解析依賴關係(例如,上面的javaFooBar)。這怎麼激活?
如何正確構建使用javax.inject的Play 2.0 Java項目?
非常感謝!
編輯:
擴展項目庫列表/ plugins.sbt通過以下方式奏效了:
// The repositories
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases"),
Resolver.typesafeRepo("snapshots"),
Resolver.typesafeRepo("releases")
)
由多諾萬描述的dependencies
命令非常有用,檢查是否依賴關係可以解決或不!
嘗試刪除常春藤本地緩存。 –
因此,我刪除了我的主目錄中的完整.ivy2目錄,'clean','update'和'eclipse with-source = true',它拋出了與發佈時相同的錯誤:/ –
也許您需要添加一些解析器。 類似於:'解析器+ = 「Sonatype OSS快照」位於「https://oss.sonatype.org/content/repositories/snapshots」' –