Monday, 15 January 2018

External Properties in Liferay DXP

1> Add below entry in portal-ext.properties
    PropertiesLocation=D:/liferay-dxp-digital-enterprise-7.0-sp3/external.properties

2> Now you can add keys in external properties file.
    Example:-
    key1 = external_Id

3> Use above key using below java code..


         /**
 * Getting the location holding file containing data 
 *
 * @param queryString
 * @return
 */
public static String getPropertiesContent(final String queryString) {
final Properties properties = new Properties();
try {
final FileReader reader = new FileReader(
        PropsUtil.get("PropertiesLocation"));
properties.load(reader);
} catch (final IOException e) {
return "File path not found";
}
return properties.getProperty(queryString, "");
}

4> Now you can use like below
keyName=<ClassName>.getPropertiesContent(
        "key1" );

No comments:

Post a Comment