cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

project.properties issue

Former Member
0 Likes
982

hello all i want to add a hardcoded code in my controller so i add this in my project.properties myWebservices.v2.erpUrl=www.facebook.com and i called it from my controller like this

 private static final String the url= "myWebservices.v2.erpUrl"

but the url prints "myWebservices.v2.erpUrl" not the value i want , what iam missing here ?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

This is not the best solution.

Config.getParameter("myWebservices.v2.erpUrl")

As indicated you can/should use the configurationService. This is the better solution as this would make unittesting easier (more loosely coupled) compared to Config. The configurationService can be mocked.

configurationService.getConfiguration().getString(url)

former_member1320010
Participant
0 Likes

you can also use the services class provided -> configurationService.getConfiguration().getString(url)

arvind-kumar_avinash
Active Contributor
0 Likes

Please use the following code:

 import de.hybris.platform.util.Config;
 String url = Config.getParameter("myWebservices.v2.erpUrl");

Please note that you should first check if your configuration has been loaded or not. To do this, you can do any of the following:

a. Go to hAC > Platform > Configuration and enter myWebservices.v2.erpUrl in the Search field. It should display a Key as myWebservices.v2.erpUrl and its Value as www.facebook.com.

b. Go to hAC > Console > Scripting Languages. Ensure that Script type is set to groovy and enter the following code in the input box > Click Execute. The Result tab should display www.facebook.com.

 import de.hybris.platform.util.Config
 url = Config.getParameter("myWebservices.v2.erpUrl")
 println url
Former Member
0 Likes

will try it and tell you