Pergunta

I am working on a project using the latest version of the Play Framework, i.e. version 2.2, and I would like to include the Twitter4j library within the classpath in order to integrate my web application with the twitter service. What is the best way of accomplishing this?

Foi útil?

Solução

playframework uses sbt to manage dependencies. just add twitter4j dependency in your build.sbt file and it will be downloaded and added to classpath.

add dependency in your build.sbt like below

  libraryDependencies += "org.twitter4j" % "twitter4j-core" % "2.1.4"

Please see below link

http://www.playframework.com/documentation/2.2.0/SBTDependencies

Outras dicas

There are two approaches:

  1. Create a lib/ folder inside your Play application and drop your jar files into that. SBT (the build tool used by Play) will automatically take care of adding the jars to the classpath.

  2. Tell SBT to fetch the jar file for you. Add the following lines to your project/Build.scala:

val twitter4j       = "org.twitter4j" % "twitter4j-core" % "3.0"
resolvers += "twitter4j-repo" at "http://twitter4j.org/maven2"

Then update appDependencies to look like below:

val appDependencies = Seq(
    ...
    twitter4j
)

Next time you run Play or issue reload at the Play prompt, SBT will handle the classpath for you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top