我正在读这篇文章
https://playframework.github.io/play-soap/SbtWsdl.html
并基于此。我写了以下build.sbt文件
name := "PlaySOAPClient"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"com.typesafe.play" % "play-soap-client_2.11" % "1.1.3"
)
WsdlKeys.packageName := Some("com.foo")
WsdlKeys.wsdlTasks in Compile := Seq(
WsdlKeys.WsdlTask((sourceDirectory.value / "main" / "wsdl" / "foo.wsdl").toURI.toURL)
)
和plugins.sbt
resolvers += Resolver.url("play-sbt-plugins", url("https://dl.bintray.com/playframework/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.typesafe.sbt" % "sbt-play-soap" % "1.1.3")
当我执行sbt compile
时,插件会生成一些代码。但该代码无法编译
Error:scalac: missing or invalid dependency detected while loading class file 'PlaySoapClient.class'.
Could not access type Configuration in value play.api,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'PlaySoapClient.class' was compiled against an incompatible version of play.api.
Warning:scalac: Class javax.inject.Singleton not found - continuing with a stub.
/Users/User/IdeaProjects/PlaySOAPClient/target/scala-2.11/wsdl/main/sources/com/foo/webservices/FooWebService.scala
Error:(13, 8) object inject is not a member of package javax
@javax.inject.Singleton
Error:(14, 107) object api is not a member of package play
class FooWebService @javax.inject.Inject() (apacheCxfBus: play.soap.ApacheCxfBus, configuration: play.api.Configuration) extends play.soap.PlaySoapClient(apacheCxfBus, configuration) {
Error:(14, 32) object inject is not a member of package javax
class FooWebService @javax.inject.Inject() (apacheCxfBus: play.soap.ApacheCxfBus, configuration: play.api.Configuration) extends play.soap.PlaySoapClient(apacheCxfBus, configuration) {
有没有人知道缺少哪些依赖项。请注意,这是一个仅使用此库进行soap调用的客户端应用程序。我不希望播放框架的任何服务器端依赖。
我希望我可以在我的控制台应用程序中使用play-soap作为独立库来拨打肥皂。
答案 0 :(得分:1)
将依赖项添加到 build.sbt
libraryDependencies += "com.typesafe.play" %% "play" % "2.6.7" intransitive()
然后sbt compile
应该有效(在sbt update
之后)。
答案 1 :(得分:0)
老实说,仅出于WSDL客户端的考虑,将整个Play框架包含到应用程序中似乎太多了。您所需要做的就是生成带注释的Java Bean,并对它们进行依赖。您实际上可以使用通用工具来做到这一点,即使用Java的wsimport
和sbt
任务将其包装起来。
为此,请考虑以下引导模板:https://github.com/sainnr/sbt-scala-wsdl-template。它会在运行中生成所有样板文件,在主sbt
项目之前进行编译,并且无需将此样板Java代码提交到原始的Scala存储库。如果您注意到了,它甚至不需要完整的应用程序服务器,只需插入一些JavaEE风格的库,例如rt.jar
或其他类似的库。希望能对某人有所帮助。