Sunday, 5 November 2017

Read value from properties file in liferay 7

 You need to add your portlet.properties under resource folder.

portlet.properties
custom.liferay.base.url = "http://liferay-article.blogspot.in/"

To read it in your java class

You need to import

import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil;

and use below code to read from properties file
Configuration configuration = ConfigurationFactoryUtil.getConfiguration(PortalClassLoaderUtil.getClassLoader(), "portlet");
System.out.println("liferay custom url->" +configuration.get("custom.liferay.base.url"));

TEST

I am Java Developer. I have 6 year Experiance in this field and like to post in blogging. So keep sharing and like my post

2 comments:

  1. Great !!, Thank you so much, I thought this was impossible, because there is only information about the properties file for the portal, and not at portlet level.

    Now, would it be possible to do it but with a yaml file?

    ReplyDelete
  2. While assessing the property is practically similar to having your own due persistence measure in progress. Try not to accept all that you see and unquestionably examine anything of inquiry. sell a property

    ReplyDelete

 

Copyright @ 2017 Liferay Article.