Can I read property file with jetty in development?

I am working on a lift project as a sub-project in a gigantic mvn project. I put the property files into:

  • src/main/resources/props/staging.props
  • src/main/resources/props/production.props

in the sub-project folder.

Then I run jetty with:

mvn jetty:run -Drun.mode=staging

I printed out the settings from net.liftweb.util.Props using:

println("file_name:" + Props.fileName)
println("mode_name:" + Props.modeName)

The output:


The mode name is correct. However, the file name is totally wrong. net.liftweb.util.Props is still using the file name that had been hardcoded in the source. It seemed never reached my property file.

Am I missing something? Or it cannot work with jetty?


While duffymo is right and you can just use the underlying servlet facilities for getting resources, I would still use Lift's Properties abstraction. It already does the work for differentiating different run modes. It also allows you to have different properties per-user and/or per-machine, which can be useful, depending on your development team.

The default properties for a given mode should be put in /props/modeName.default.props, so your files should be renamed to:

  • src/main/resources/props/staging.default.props
  • src/main/resources/props/production.default.props

I would put the .properties file in your /WEB-INF/classes and use the servlet context's getResourceAsStream() to read it in.

Need Your Help

Use multiple stemming languages with ElasticSearch

lucene elasticsearch stemming snowball

I'm building a search engine for a website where users can be of many different countries and post text content.

Java Multiplication of static fields?

java multiplication

This is probably the most obvious question on stackoverflow. Please Help! What is wrong with this code?