6

由于我渴望在我的 Play 2 项目中使用 Elastic Search,我已经阅读了 http://www.elasticsearch.org/guide/reference/java-api/并添加了依赖项:

构建.scala:

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "test"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      // Add your project dependencies here,
      "mysql" % "mysql-connector-java" % "5.1.18",      
      "org.elasticsearch" % "elasticsearch" % "0.19.10"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here
      resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://cleverage.github.com/play2-elasticsearch/releases/"))(Resolver.ivyStylePatterns)      
    )
}

找到并下载依赖项,检查播放依赖项:

Here are the resolved dependencies of your application:

+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| Module                                                            | Required by                                             | Note                               |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.elasticsearch:elasticsearch:0.19.10                           | test:test_2.9.1:1.0-SNAPSHOT                            | As elasticsearch-0.19.10.jar       |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.apache.lucene:lucene-highlighter:3.6.1                        | org.elasticsearch:elasticsearch:0.19.10                 | As lucene-highlighter-3.6.1.jar    |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.apache.lucene:lucene-memory:3.6.1                             | org.elasticsearch:elasticsearch:0.19.10                 | As lucene-memory-3.6.1.jar         |
|                                                                   | org.apache.lucene:lucene-highlighter:3.6.1              |                                    |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.apache.lucene:lucene-queries:3.6.1                            | org.elasticsearch:elasticsearch:0.19.10                 | As lucene-queries-3.6.1.jar        |
|                                                                   | org.apache.lucene:lucene-highlighter:3.6.1              |                                    |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| jakarta-regexp:jakarta-regexp:1.4                                 | org.apache.lucene:lucene-queries:3.6.1                  |                                    |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.apache.lucene:lucene-analyzers:3.6.1                          | org.elasticsearch:elasticsearch:0.19.10                 | As lucene-analyzers-3.6.1.jar      |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| org.apache.lucene:lucene-core:3.6.1                               | org.apache.lucene:lucene-analyzers:3.6.1                | As lucene-core-3.6.1.jar           |
|                                                                   | org.apache.lucene:lucene-queries:3.6.1                  |                                    |
|                                                                   | org.elasticsearch:elasticsearch:0.19.10                 |                                    |
|                                                                   | org.apache.lucene:lucene-memory:3.6.1                   |                                    |
|                                                                   | org.apache.lucene:lucene-highlighter:3.6.1              |                                    |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| mysql:mysql-connector-java:5.1.18                                 | test:test_2.9.1:1.0-SNAPSHOT                            | As mysql-connector-java-5.1.18.jar |
+-------------------------------------------------------------------+---------------------------------------------------------+------------------------------------+
| play:play_2.9.1:2.0.3                                             | test:test_2.9.1:1.0-SNAPSHOT                            | As play_2.9.1.jar                  |
...

但是在eclipse中我不能使用elasticsearch,因为它找不到库。我什至无法导入它。

我在这里想念什么?

4

2 回答 2

13

添加新依赖项后(即更新文件后) ,您必须eclipsify在 Play 控制台中重做。Build.scala

它将.classpath为 Eclipse 生成一个包含新依赖项的新文件。

于 2012-10-04T14:17:31.607 回答
1

如果 Build.scala 设置正确,并且在新生成的 .classpath 文件中找到了有关所需库的信息,则尝试运行play eclipsify如果它不起作用,只需重新启动 Eclipse。它对我有用。

于 2012-12-10T00:27:17.447 回答