以下代码可解决达成jar包部署读取不到文件内容问题,代码如下:
public static String getFileJson() throws IOException {
ClassPathResource classPathResource = new ClassPathResource("service.json");
byte[] bytes= FileCopyUtils.copyToByteArray(classPathResource.getInputStream());
rturn new String(bytes);
}