Props file example

16 views
Skip to first unread message

Guillermo Acilu

unread,
Oct 12, 2009, 8:42:56 AM10/12/09
to Lift
Hello guys,

I am starting to learn Lift and I have a very silly question.

I am using postgresql and I have seen that the file boot.scala reads
the configuration parameters like connect string, user name and
password, from a properties file called Props. I could not find an
example of such a file in any document or in google. Is it a XML file
or a simple java.properties file? Could you please send me an small
example?

Thanks in advance,

GA

Peter Robinett

unread,
Oct 12, 2009, 9:36:05 AM10/12/09
to Lift
It's a simple java.properties file. You should place it in src/main/
resources/props. There is a search order but, off the top of my head,
the last two options are the username running the app (e.g.
peter.props) and default.props.

My peter.props looks like this:
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/myDB
db.user=myUser
db.password=myPassword
isPeter=true

Notice that you can define your own properties.

Peter Robinett

Timothy Perrett

unread,
Oct 12, 2009, 9:52:12 AM10/12/09
to lif...@googlegroups.com

Note that you can also intermix this with runtimes:

default.props
default.pilot.props

Doing something like that can let you automatically load different
properties based on the run mode lift is in (production vs dev etc)

Your code will still look like:

Props.get("some.key") //=> Box[String]

HTH

Cheers, Tim

my_l...@me.com

unread,
Oct 12, 2009, 9:43:25 AM10/12/09
to lif...@googlegroups.com
Thanks for the information

my_l...@me.com

unread,
Oct 12, 2009, 9:55:51 AM10/12/09
to lif...@googlegroups.com
And how do I switch runtimes? within the boot.scala?

Richard Dallaway

unread,
Oct 13, 2009, 8:16:35 AM10/13/09
to lif...@googlegroups.com
On Mon, Oct 12, 2009 at 2:55 PM, <my_l...@me.com> wrote:
>
> And how do I switch runtimes? within the boot.scala?

If I need to, I change the run mode at start up time:

$ MAVEN_OPTS="-Drun.mode=pilot" mvn jetty:run

...if that helps

Richard

Reply all
Reply to author
Forward
0 new messages