我想知道是否可以通过@Autowired 以某种方式将 bean 形式的 xml 文件注入(inject)到 Liferay Hook 中。在这种特殊情况下,我使用 UpgradeProcess Hook 。我的项目已经配置为将 Spring 与 liferay 一起使用,我可以使用 ClassPathXmlApplicationContext 的 getBean("bean name") 方法解码 xml,但如果这能自动发生会更好。
问候!
最佳答案
这是可能的。
将应用程序的 web.xml
监听器类配置为 org.springframework.web.context.ContextLoaderListener
并将 applicationContext.xml
放在 WEB-INF
文件夹。它将从您的 applicationContext.xml
中选择相应的 bean,您可以在 bean 中 Autowiring 这些对象。
干杯
关于spring - 是否可以在 Liferay Hook 中使用 Spring @Autowired?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11516994/