ClassLoader classLoader = getClass().getClassLoader();
File fXmlFile = new File(classLoader.getResource("XMLDocument/DoctypesConfig.xml").getFile());
它在本地运行良好,生成docker映像并部署到AWS fargate容器中后会引发异常,
"error_message": "/usr/local/bin/file:/usr/local/bin/app.jar!/BOOT-INF/classes!/XMLDocument/DoctypesConfig.xml (No such file or directory)"
我的资源文件夹结构,
答案 0 :(得分:2)
在路径前面添加一个斜线:
File fXmlFile = new File(classLoader.getResource("/XMLDocument/DoctypesConfig.xml").getFile());