<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.5</version>
</dependency>
public String getContent(String path){
try {
File file = ResourceUtils.getFile("classpath:"+path); //获取项目路径中的文件
return FileReader.create(file).readString(); //读取字符串
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}