When you recently modified the XX application, it involved the need to read the project configuration file in the jar package. In the jar package, the configuration file is read and needs to be handled separately.
Some of the configuration files in the project, such as Dbconfig.properties log4j.xml do not want to be packaged into jars.
Because some of these configuration information may be modified, packaged into the jar, it becomes awkward and inconvenient to modify the file.
You can read the external configuration file in the jar package in the following way.
Method One:
Key code.
To read the properties file method:
InputStream ins = GetClass (). getResourceAsStream ("/resource/dbconfig.properties");
But Log4j.xml needs to be dealt with separately:
Propertyconfigurator.configure (System.getproperty ("User.dir") + "/resource/log4j.xml");
Method Two:
The configuration files Out.properties and Jiar packages are under the same directory:
FileInputStream inputStream1 = new FileInputStream ("out.properties");
Configuration file In.properties inside the jar package:
InputStream inputStream2 = A.class.getresourceasstream ("/in.properties");
Jar reads external and internal configuration file issues