I have two Java Projects, and I am trying to read the properties file in one from another. I have added "Infrastructure" Project in Build path of "Java" Project, and the properties file is at root folder, but I am getting java.io.FileNotFoundException
I tried bunch ways, but couldn't make it work. Which part is causing the problem?
public static void main(String[] args) throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream("application.properties"));
}
Here is the Project Explorer;
使用: properties.load(YourClass.class.getResourceAsStream("/application.properties"))
代替。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.