CodeMonkey CodeMonkey - 1 month ago 14
Java Question

How to add AWS Java SDK to Scala / Play project

I'm playing around with Scala and Play, where I want to use the AWS Java SDK.

I need to add the SDK to the project. And I know that I need to do that using the

plugins.sbt
.

What I have tried

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

addSbtPlugin("com.amazonaws" % "aws-java-sdk" % "1.11.46")


It's saying:

unresolved dependencies: Error:Unresolved dependencies:com.amazonaws#aws-java-sdk;1.11.46: not found`


As I am new to both Java, Scala and sbt I can't figure out what I am doing wrong.

The solution

I was wrong about where to put the reference. It goes in
build.sbt
as it is not an sbt plugin, but rather a framework for the application to use.

Add the reference to
build.sbt
like this:

libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.11.46"
)


And you are good to go. You don't need a reference to any repositories, since the aws sdk is available in the default repos.

See a list of available AWS Java SDK versions

Answer

Your problem is with SBT, the framework needs to be placed within build.sbt but you're trying to import it in as a plugin which it is not. Try this out, remove the plugin above, and put this line within your build.sbt

esolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
libraryDependencies ++= Seq(
  "com.amazonaws" % "aws-java-sdk" % "1.11.46"
)

The have sbt build from there. If your in intelli j you can enable auto-import and have sbt automatically begin importing new or modified dependencies.