<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to inject spring bean in liferay service module.</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112171351" />
  <subtitle>How to inject spring bean in liferay service module.</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112171351</id>
  <updated>2026-04-03T23:05:55Z</updated>
  <dc:date>2026-04-03T23:05:55Z</dc:date>
  <entry>
    <title>RE: How to inject spring bean in liferay service module.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112205429" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112205429</id>
    <updated>2019-02-01T19:51:37Z</updated>
    <published>2019-02-01T19:51:37Z</published>
    <summary type="html">The spring MVC Portlet is a WAR right? Try exporting that package in liferay-plugin-package.properties.&lt;br /&gt;​​​​​​​&lt;br /&gt;&lt;a href="https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/exporting-packages"&gt;https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/exporting-packages&lt;/a&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2019-02-01T19:51:37Z</dc:date>
  </entry>
  <entry>
    <title>How to inject spring bean in liferay service module.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112171350" />
    <author>
      <name>Mohit Mehral</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112171350</id>
    <updated>2019-01-30T06:46:26Z</updated>
    <published>2019-01-30T06:46:26Z</published>
    <summary type="html">Hi Everyone,&lt;br /&gt;&lt;br /&gt;I am using Liferay dxp.&lt;br /&gt;&lt;br /&gt;I need help in using the spring bean in liferay service module created using service builder.&lt;br /&gt;&lt;br /&gt;I have created a spring mvc portlet using Liferay LDS and created one bean as Demo.java(having some getters and setters in it).&lt;br /&gt;spring xml file is &lt;br /&gt;&amp;#34;&amp;lt;?xml version=&amp;#34;1.0&amp;#34;?&amp;gt;&lt;br /&gt; &lt;br /&gt;&amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34;&lt;br /&gt;    xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;&lt;br /&gt;    default-destroy-method=&amp;#34;destroy&amp;#34; default-init-method=&amp;#34;afterPropertiesSet&amp;#34;&lt;br /&gt;    xsi:schemaLocation=&amp;#34;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&amp;#34;&amp;gt;&lt;br /&gt;    &amp;lt;bean id=&amp;#34;com.lifery.practice.Demo&amp;#34; class=&amp;#34;com.lifery.practice.Demo&amp;#34; /&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&amp;#34;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In my service module(LocalServiceImpl file) i have referenced it as &lt;br /&gt;&lt;br /&gt;@BeanReference(type=Demo.class)&lt;br /&gt;private Demo demo;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have resolved the compile time dependency using below line in build.gradle&lt;br /&gt;compileOnly project(&amp;#34;:wars:Example&amp;#34;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When i try to start my service module through gogo shell i am getting below error&lt;br /&gt;&lt;br /&gt;org.osgi.framework.BundleException: Could not resolve module: .service [960]&lt;br /&gt;  Unresolved requirement: Import-Package: com.lifery.practice&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I am stuck here.&lt;br /&gt;&lt;br /&gt;Do we have register the bean in application context?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How to acheive this scenario?? Please help!!!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;​​​​​​​Mohit Mehral.</summary>
    <dc:creator>Mohit Mehral</dc:creator>
    <dc:date>2019-01-30T06:46:26Z</dc:date>
  </entry>
</feed>
