When using bundle to load the configuration file, this error broke out:
why
The configuration file to be loaded was not found because it must be placed under the SRC directory
If you put it under the package of com.bj186.crm, you must add the package name to the pathname of the configuration file
// use bundle
@Test
public void test4() {
// ResourceBundle is a tool class specifically designed to read configuration files
// bundle can only read properties type files, only the file name is needed when reading, no suffix is needed
// bundle also provides an iterative method to read all configurations
ResourceBundle db = ResourceBundle.getBundle("db");
db.getString("driver");
Enumeration<String> keys = db.getKeys();
while(keys.hasMoreElements()) {
String key = keys.nextElement();
System.out.println(key +": " + db.getString(key));
}
}
The solution
Move dB. Properties to SRC directory and solve the problem
In this way, the subproblem can be solved
Similar Posts:
- Error: Can’t find bundle for base name messages.AndroidJpsBundle, locale en_US
- After project initialization, it appears: unable to load script from assets’ index.android.bundle
- Logback: solve the problem that logback.xml configuration doesn’t work
- [Solved] JAVA:java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcodbcDrive
- package wang/test is not in GOROOT (/usr/local/go/src/wang/test)
- Eclipse Error:The selection cannot be launched, and there are no recent launches
- IDEA compile error: sun.misc.Base64decoder upgrade processing
- [Solved] JAVA Beginners’ Error: Exception in thread “main“ java.io.FileNotFoundException
- Eclipse Off-line Install activiti Plug-in error: “An error occurred while collecting items to be installed session conte…
- Solution to the problem of Java program “resource leak: ‘SC’ is never closed” in vscode