Why the elevator cannot find my "db.properties"

In the elevator project, I installed the db configurations in a file called db.properties

 /src/main/resources/db.properties 

And in my Boot.scala , I read it as:

 val input = this.getClass.getResourceAsStream("db.properties") println("### input: " +input) val db = new java.util.Properties db.load(input) val url = db.getProperty("url") println("#### url:" + url) 

Then I start sbt:

 sbt prepare-web jetty-start 

The console prints some errors:

 ### input: null 21:48:55.906 [main] ERROR n.liftweb.http.provider.HTTPProvider - Failed to Boot! Your application may not run properly java.lang.NullPointerException: null at java.util.Properties$LineReader.readLine(Properties.java:418) ~[na:1.6.0_27] at java.util.Properties.load0(Properties.java:337) ~[na:1.6.0_27] at java.util.Properties.load(Properties.java:325) ~[na:1.6.0_27] at bootstrap.liftweb.Boot.boot(Boot.scala:21) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6. 

Strange climb can't find db.properties !

I checked target/webapp/WEB-INF/classes , and db.properties is there! Where is it wrong?

+4
source share
1 answer

The code you posted should work - you can try

val input = getClass.getResourceAsStream("/db.properties")

Alternatively, you can try the built-in Lift Props meccano stand: http://www.assembla.com/wiki/show/liftweb/Properties

If you use Mapper (= the permanent structure that comes with the elevator), you can see: http://www.assembla.com/spaces/liftweb/wiki/Mapper

If all else fails, ask the friendly elevator community: http://groups.google.com/group/liftweb

Hope this helps Paul

+1
source

Source: https://habr.com/ru/post/1381126/


All Articles