WS.url("https://api.humanapi.co/v1/human"+url+"?updated_since="+updatedSince).setHeader("Authorization", "Bearer "+accessToken)
.setHeader("Accept", "application/json").get().map(
new Function<WSResponse, JsonNode>() {
public JsonNode apply(WSResponse response) {
JsonNode json = response.asJson();
success(json);
return json;
}
}
);
这会显示错误“无法解析类型 scala.concurrent.ExecutionContext。它是从所需的 .class 文件间接引用的”。
我试过添加
import scala.concurrent.ExecutionContext;
但是错误只是从 promise 所在的行“移动”到文件的顶部,仍然无法编译。
我也试过添加
import play.api.libs.concurrent.Execution.Implicit.defaultContext;
但是没有导入这个东西。
使用的 Play Framework 是 2.4.2。
SBT 文件:
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.6"
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
"sonatype snapshots" at "https://oss.sonatype.org/content/repositories/releases/"
)
checksums := Nil
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
"org.mockito" % "mockito-all" % "1.10.19",
"commons-codec" % "commons-codec" % "1.10",
"de.flapdoodle.embed" % "de.flapdoodle.embed.mongo" % "1.48.0",
"org.mongodb.morphia" % "morphia" % "1.0.0-rc0"
)
libraryDependencies += "org.mongodb" % "mongodb-driver" % "3.0.2"
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
最佳答案
我遇到了同样的问题并意识到我的 Play Eclipse 设置不完整(我错过了下面的步骤 2 和 3)。我重试了设置,这次遵循了所有相关步骤。 ExecutionContext 变得可解析。
Play Eclipse 安装说明
原始引用:https://www.playframework.com/documentation/2.4.x/IDE
更新引用:https://www.playframework.com/documentation/2.5.x/IDE
1) 将此行附加到 project/plugins.sbt:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
2) 将此行附加到 build.sbt:
EclipseKeys.preTasks := Seq(compile in Compile)
3) 将这些行附加到 build.sbt(假设您没有 Scala 源代码):
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java // Java project. Don't expect Scala IDE
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources) // Use .class files instead of generated .scala files for views and routes
4) 保存所有项目文件。关闭 Eclipse。
5) 在命令提示符下,cd 到您的项目文件夹并运行:
activator "eclipse with-source=true"
6) 打开 Eclipse。打开你的项目。刷新如下:
Package Explorer > 右键单击 your_project > refresh
关于java - Play Framework - 尝试映射 Promise 时无法解析 ExecutionContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31511143/
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/