springboot读取文件
方式一
ClassPathResource cp = new ClassPathResource("shiro_base_auth.ini");
File file = cp.getFile();
InputStream inputStream = cp.getInputStream();
pom配置 打成jar包将文件放在哪里。要不打包后访问不到
<fileSet>
<!-- 项目中 input.txt所在目录。-->
<directory>./input/input.txt</directory>
<!-- 打包之后 input.txt所在目录-->
<outputDirectory>./conf</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.xml</include>
<include>mapper/*.xml</include>
<include>**/*.*</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>