How to create a hook using spring annotation?How to create a hook using spring annotation?https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=748781802024-03-29T01:29:34Z2024-03-29T01:29:34ZHow to create a hook using spring annotation?S Hhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=748781792016-06-03T03:01:28Z2016-06-03T03:01:28ZI am following this article https://dev.liferay.com/discover/deployment/-/knowledge_base/6-2/custom-java-tools-in-the-script-engine to create a hook. It is using xml to config spring which is working fine.<br /><br />However, I'd like to try using annotation. So I tried to change below files.<br /><br />Change hook-spring.xml to<br /><beans ......><br /> <context:annotation-config /><br /> <context:component-scan base-package="com.liferay.sample" /><br /></beans><br /><br />And the implementation class become<br />package com.liferay.sample;<br />import org.springframework.stereotype.Component;<br />@Component<br />public class ScriptUtilImpl implements ScriptUtil {<br /> @Override<br /> public String operationOne() {<br /> return "Hello out there!"; <br /> }<br /> @Override<br /> public String operationTwo(String name) {<br /> return "Hello " + name + "!"; <br /> }<br />}<br /><br />The rest configuration remain same as that article mentioned.<br /><br />However, when I execute the code, I see below error in the log. Is there any difference between using xml or annotation in spring in the hook?<br /><br />org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.liferay.sample.ScriptUtil' is defined<br />Line 1: myUtil = com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(<br />Line 2: "script-utils-hook", "com.liferay.sample.ScriptUtil")<br />Line 3: <br />Line 4: println(myUtil.operationOne())<br />Line 5: <br />Line 6: println(myUtil.operationTwo("J