Sometimes we need to change some of values defined for properties key in local.properties/project.properties. There are three ways to do it
- Update via HAC
- Update Local.properties
- Update using beanshell/groovy script
If we use the first process, after server re-start, changes will go. So, the value will remain in the system memory till the server got re-started.
Here, will give an example how to change local.properties and changes remain even after rebuild.
Run the below script in the HAC script tab with "commit" on.
import org.apache.commons.configuration.PropertiesConfiguration;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
//The new value to be stored in the key/value pair in local.properties.
String changedValue = "NEW_VALUE";
//Key name in the local.properties
String propertyName = "test.properties.value";
PropertiesConfiguration config = new PropertiesConfiguration((new File('<Hybris Config Dir>/local.properties').getAbsolutePath()));
println config.getProperty(propertyName );
config.setProperty(propertyName, changedValue );
config.save();
Here, will give an example how to change local.properties and changes remain even after rebuild.
Run the below script in the HAC script tab with "commit" on.
import org.apache.commons.configuration.PropertiesConfiguration;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
//The new value to be stored in the key/value pair in local.properties.
String changedValue = "NEW_VALUE";
//Key name in the local.properties
String propertyName = "test.properties.value";
PropertiesConfiguration config = new PropertiesConfiguration((new File('<Hybris Config Dir>/local.properties').getAbsolutePath()));
println config.getProperty(propertyName );
config.setProperty(propertyName, changedValue );
config.save();
Beanshell/Groovy Example - Change Local.Properties Permanently Using Script >>>>> Download Now
ReplyDelete>>>>> Download Full
Beanshell/Groovy Example - Change Local.Properties Permanently Using Script >>>>> Download LINK
>>>>> Download Now
Beanshell/Groovy Example - Change Local.Properties Permanently Using Script >>>>> Download Full
>>>>> Download LINK IK