在应用程序初始化期间,Swagger-play会抛出异常

时间:2016-02-23 00:01:25

标签: scala playframework dependency-injection swagger

当我尝试将Swagger附加到Play Framework应用时,我遇到了问题。 Swagger lib扫描未初始化的类并导致问题。有什么建议如何处理它?<​​/ p>

我提取了应用程序的一部分作为示例:

https://github.com/mgosk/play-swagger-example

CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.RuntimeException: There is no started application
  at auth.services.AuthService.<init>(AuthService.scala:24)
  while locating auth.services.AuthService
    for parameter 0 at auth.AnonymousAuthController.<init>(AuthController.scala:16)
  while locating auth.AnonymousAuthController
    for parameter 1 at router.Routes.<init>(Routes.scala:43)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
    for parameter 1 at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:33)
  while locating play.modules.swagger.SwaggerPluginImpl
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.modules.swagger.SwaggerPlugin

1 个答案:

答案 0 :(得分:0)

问题是在最新的,未记录的招摇版中修复的。只需使用:

libraryDependencies ++= Seq(
  "io.swagger" %% "swagger-play2" % "1.5.3"
)