Skip to content

Instantly share code, notes, and snippets.

@baxtheman
Created October 4, 2019 13:30
Show Gist options
  • Save baxtheman/0b7f84d179f4f2dc8b59d75dae5c552f to your computer and use it in GitHub Desktop.
Save baxtheman/0b7f84d179f4f2dc8b59d75dae5c552f to your computer and use it in GitHub Desktop.
Read value from properties file in liferay 7

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

portlet.properties
custom.liferay.base.url = "https://www.liferay.com/"

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"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment