简体   繁体   中英

How can I load web3j library to an sbt project?

I want to load web3j to an sbt project running in Intellj IDE and based on play framework. I tried to add

libraryDependencies += "org.web3j" % "web3j-maven-plugin" % "0.1.2"

in build.sbt but I got errors. Any ideas?

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]

First of all, please update the question with the specific error you're getting.

What the issue could be is the usage of "%%" between the group id and artifactId. It only makes sense for scala dependencies to append the version of scala of your project to the artifact id of the dependency . Since web3j is written in Java, not scala, it doesn't make sense here. Try with the single "%".

EDIT: thanks for updating the question. Indeed sbt is looking for an artifact called web3j-maven-plugin_2.12, because it appended the scala version of your project to the artifact id.

I didn't post the error because I thought that adding

libraryDependencies += "org.web3j" %% "web3j-maven-plugin" % "0.1.2"

was totally wrong way to do this.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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