http://jrails.iteye.com/blog/1705464
‘
In general, when using the properties configuration file in the project, the relevant properties file is placed in the SRC directory, after the app is packaged to generate the jar, the corresponding properties profile ...
Typically when you use the properties profile in your project, the relevant properties file is placed in the SRC directory, and the corresponding properties profile is generated in the jar package after the app is packaged to generate the jar. In this case, it is quite troublesome to modify the configuration file and re-hit the jar package.
Since this is so troublesome, you certainly want to put the configuration file in the other directory, the generated jar package does not contain the corresponding configuration file, modify the configuration file without repackaging, yes, here is a solution.
Read inside the jar package configuration file:
this. getclass (). getClassLoader (). getResourceAsStream ("/configfilename.properties
To read the jar out-of-package configuration file:
String FilePath = System.getproperty ("User.dir") + "/conf/configfilename.properties"; New Bufferedinputstream (new
In addition, if the app uses the Log4j.properties file, the default storage path is src/ Log4j.properties, as above, I want to put log4j.properties in other directories, so that you do not need to re-play the jar when modifying the log4j configuration file.
Add the following code to the first line of the main function:
How to read the properties file and log4j.properties outside the jar package