找不到配置文件
Properties properties = new Properties(); String configPath = String.valueOf(ConnectionOperation.class.getResource("/druid-config.properties")); configPath = URLDecoder.decode(configPath, "UTF-8"); properties.load(new FileInputStream(configPath));
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: file:/Users/lewisqin/Desktop/java/Idea/news-dbutils/target/classes/druid-config.properties (No such file or directory) at com.imooc.news.connection.ConnectionOperation.getConnection(ConnectionOperation.java:31) at com.imooc.news.command.PaginationCommand.execute(PaginationCommand.java:19) at com.imooc.news.Application.main(Application.java:34) Caused by: java.io.FileNotFoundException: file:/Users/lewisqin/Desktop/java/Idea/news-dbutils/target/classes/druid-config.properties (No such file or directory) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:219) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:158) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112) at com.imooc.news.connection.ConnectionOperation.getConnection(ConnectionOperation.java:20)
使用getResource方法寻找配置文件 报错, 项目目录如图所示。
7
收起
正在回答 回答被采纳积分+1
1回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星