Running this Maven project from Eclipse this does not work:
MyClass.class.getResourceAsStream("/package/to/my/resource/" + ".gitignore");
But when I rename the .gitignore
to gitignore
this works pretty fine:
MyClass.class.getResourceAsStream("/package/to/my/resource/" + "gitignore");
The resource files are located under src/main/resources/package/to/my/resource/
. The maven-resources-plugin
is not configured in the pom.xml.
The .* files are not moved to target/classes.
Java shouldn't have any problem with "hidden" files. You need to check the output/target folder after building the project. You should find there a /package/to/my/resource/.gitignore
file. If you cannot find it you should double check Java Build Path in project properties if there is no exclusion for files which begin with a dot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.