一 文件放在classpath下面
1. 直接获取InputStream
InputStream inputStream = Thread.currentThread() .getContextClassLoader().getResourceAsStream("user_table.xml");
2. 获取resource和path
URL resource = Thread.currentThread().getContextClassLoader() .getResource("user_table.xml"); String path = resource.getPath();
时间: 2024-10-09 09:11:02