如何将web3j库加载到sbt项目?

时间:2018-04-06 23:13:15

标签: java intellij-idea sbt playframework-2.3 web3-java

我想将web3j加载到在Intellj IDE中运行并基于play框架的sbt项目。我试着添加

libraryDependencies += "org.web3j" % "web3j-maven-plugin" % "0.1.2"
build.sbt中的

但是我遇到了错误。有什么想法吗?

Error while importing sbt project:

[info] Loading settings from idea.sbt ...
[info] Loading global plugins from C:\Users\christos\.sbt\1.0\plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from C:\Users\christos\cryptolotto\project
[info] Loading settings from build.sbt ...
[info] Set current project to cryptolotto (in build file:/C:/Users/christos/cryptolotto/)
[info] sbt server started at local:sbt-server-b84ab1850f860119aa36
[cryptolotto] $
[info] Defining Global / sbtStructureOptions, Global / sbtStructureOutputFile, shellPrompt
[info] The new values will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to cryptolotto (in build file:/C:/Users/christos/cryptolotto/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks from C:/Users/christos/.IdeaIC2017.3/config/plugins/Scala/launcher/sbt-structure-1.0.jar
[info] Reapplying settings...
[info] Set current project to cryptolotto (in build file:/C:/Users/christos/cryptolotto/)
[info] Updating ...
[warn]  module not found: org.ethereum#solcJ-all;0.4.8
[warn] ==== local: tried
[warn]   C:\Users\christos\.ivy2\local\org.ethereum\solcJ-all\0.4.8\ivys\ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/ethereum/solcJ-all/0.4.8/solcJ-all-0.4.8.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   C:\Users\christos\.sbt\preloaded\org.ethereum\solcJ-all\0.4.8\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:/C:/Users/christos/.sbt/preloaded/org/ethereum/solcJ-all/0.4.8/solcJ-all-0.4.8.pom
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.ethereum#solcJ-all;0.4.8: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]

3 个答案:

答案 0 :(得分:2)

首先,请根据您获得的具体错误更新问题。

问题可能是使用" %%"组ID和artifactId之间。它只适用于scala依赖项to append the version of scala of your project to the artifact id of the dependency。因为web3j是用Java而不是scala编写的,所以在这里没有意义。尝试使用单个"%"。

编辑:感谢您更新问题。事实上,sbt正在寻找一个名为web3j-maven-plugin_2.12的工件,因为它将项目的scala版本附加到工件id。

答案 1 :(得分:0)

我没有发布错误,因为我认为添加了

554

完全错误的做法。

答案 2 :(得分:0)

我终于设法通过添加以下行来解决它并将web3j添加到build.sbt:

libraryDependencies += "org.web3j" % "core" % "3.3.1"