spring - 是否可以在 Liferay Hook 中使用 Spring @Autowired?

标签 spring hook liferay-6 autowired

我想知道是否可以通过@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/

相关文章:

java - 来自不同 Maven 模块的 Autowire 类?

java - Spring Cloud DataFlow 组合任务未启动

Windows 键盘 Hook 挂起调试器

java - Spring hibernate关于延迟加载的错误

java - Spring @Aspect 未正确 Autowiring

javascript - 有没有办法从页面上下文中监听幻像上下文中的事件?

C++:尝试 Hook 消息框并更改其位置

javascript - 从浏览器检查 Liferay 版本

java - Liferay Json Web服务参数输入

java - 通过 JournalStructureLocalServiceUtil Liferay 获取结构名称