Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to inject spring bean in liferay service module.
Hi Everyone,
I am using Liferay dxp.
I need help in using the spring bean in liferay service module created using service builder.
I have created a spring mvc portlet using Liferay LDS and created one bean as Demo.java(having some getters and setters in it).
spring xml file is
"<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
default-destroy-method="destroy" default-init-method="afterPropertiesSet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="com.lifery.practice.Demo" class="com.lifery.practice.Demo" />
</beans>"
In my service module(LocalServiceImpl file) i have referenced it as
@BeanReference(type=Demo.class)
private Demo demo;
I have resolved the compile time dependency using below line in build.gradle
compileOnly project(":wars:Example")
When i try to start my service module through gogo shell i am getting below error
org.osgi.framework.BundleException: Could not resolve module: .service [960]
Unresolved requirement: Import-Package: com.lifery.practice
I am stuck here.
Do we have register the bean in application context?
How to acheive this scenario?? Please help!!!
Regards,
Mohit Mehral.
I am using Liferay dxp.
I need help in using the spring bean in liferay service module created using service builder.
I have created a spring mvc portlet using Liferay LDS and created one bean as Demo.java(having some getters and setters in it).
spring xml file is
"<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
default-destroy-method="destroy" default-init-method="afterPropertiesSet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="com.lifery.practice.Demo" class="com.lifery.practice.Demo" />
</beans>"
In my service module(LocalServiceImpl file) i have referenced it as
@BeanReference(type=Demo.class)
private Demo demo;
I have resolved the compile time dependency using below line in build.gradle
compileOnly project(":wars:Example")
When i try to start my service module through gogo shell i am getting below error
org.osgi.framework.BundleException: Could not resolve module: .service [960]
Unresolved requirement: Import-Package: com.lifery.practice
I am stuck here.
Do we have register the bean in application context?
How to acheive this scenario?? Please help!!!
Regards,
Mohit Mehral.
The spring MVC Portlet is a WAR right? Try exporting that package in liferay-plugin-package.properties.
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/exporting-packages
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/exporting-packages
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™