我将 Play 2.2.1 与 Spring 4.0.1 一起用于 DI。我正在使用 deadbolt-java 版本 2.2-RC1 进行授权。每当我访问使用 Deadbolt 注释注释的任何请求处理程序时,例如:@SubjectPresent(handler = BaseDeadboltHandler.class) 我看到由 Deadbolt 生成的异常:
play.api.Application$$anon$1: Execution
exception[[NoSuchBeanDefinitionException: No qualifying bean of type
[be.objectify.deadbolt.java.actions.SubjectPresentAction] is defined]]
at play.api.Application$class.handleError(Application.scala:293)
~[play_2.10.jar:2.2.2-RC1]
at play.api.DefaultApplication.handleError(Application.scala:399)
[play_2.10.jar:2.2.2-RC1]
at
play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261)
[play_2.10.jar:2.2.2-RC1]
at
play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261)
[play_2.10.jar:2.2.2-RC1]
at scala.Option.map(Option.scala:145) [scala-library.jar:na]
at
play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261)
[play_2.10.jar:2.2.2-RC1]
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
[be.objectify.deadbolt.java.actions.SubjectPresentAction] is defined
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:318)
~[spring-beans-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:985)
~[spring-context-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at Global.getControllerInstance(Global.java:139) ~[classes/:na]
at
play.core.j.JavaGlobalSettingsAdapter.getControllerInstance(JavaGlobalSettingsAdapter.scala:46)
~[play_2.10.jar:2.2.2-RC1]
at play.core.j.JavaAction$$anonfun$8.apply(JavaAction.scala:80)
~[play_2.10.jar:2.2.2-RC1]
at play.core.j.JavaAction$$anonfun$8.apply(JavaAction.scala:77)
~[play_2.10.jar:2.2.2-RC1]
这可能是因为 Spring 正在尝试使用它的 bean 容器来管理 deadbolt 类。这可以避免吗?有没有一种方法可以告诉 Spring 不要为 deadbolt 注释寻找 bean?