Page 1 of 1

adding new properties in development.properties

Posted: Thu Nov 28, 2013 9:52 pm
by nanix84
Hi guys :)

Im so new to this. I would like to add a property
axis.server.prefix=http://localhost:8080/
how can I access the value of this property?

I have tried:
@Value("${axis.server.prefix}")
protected String esbServiceUrl;

it doesn't work. even other properties inside a .properties file doesn't seem to be pulled.
Need help on this.

Thanks

Re: adding new properties in development.properties

Posted: Sun Dec 01, 2013 12:12 am
by bpolster
development.properties should be picked up as the default "environment" for Broadleaf.

This document explains how Broadleaf uses property configuration files. http://docs.broadleafcommerce.org/core/ ... figuration

A few things to check ...
1. Make sure you are editing the development.properties in the correct project (e.g. site versus admin).
2. Check your target directory to make sure the properties files are getting copied over properly with your build process and that they contain your setting. For example, "target/mycompany/WEB-INF/classes/runtime-properties"

Re: adding new properties in development.properties

Posted: Sun Dec 01, 2013 9:19 pm
by nanix84
Hi bpolster,

The basic configuration is already applied on my project. There is already a bean "blConfiguration" on my applicationContext.
The development.properties that I edited is under: site/src/main/resources/runtime-properties/

and still to NO avail.. can't pull the values by using the JPA: @Value("${axis.server.prefix}")

please let me know if theres something I did wrong.
Thanks

Re: adding new properties in development.properties

Posted: Mon Dec 02, 2013 2:01 am
by bpolster
The Broadleaf properties files use Spring property mechanisms. The @Value annotation more specifically is :
import org.springframework.beans.factory.annotation.Value;

But ... Since you mention JPA @Value annotation. I'll assume you maybe trying to default the value of a JPA managed entity.
The spring property settings won't work for a JPA managed class since Spring does not create these entities (JPA / hibernate does).

You'll need to use a JPA pattern to create defaults for JPA managed entities. Nice thread on stack overflow for defaulting JPA managed properties can be found here: http://stackoverflow.com/questions/197045/setting-default-values-for-columns-in-jpa