我已将messagesApi
注入我的控制器documented(播放2.4.x):
@Scope(value = "singleton")
@Component
class MyController @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport
但是在开机时:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [play.api.i18n.MessagesApi] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
答案 0 :(得分:0)
您需要使用BaseController
或InjectedController
扩展您的控制器;所以你的代码将是:
class MyController @Inject()(val messagesApi: MessagesApi) extends InjectedController with I18nSupport{}
有关详细信息,请查看Play documents。