普通java工程的resources目录寻址

问题:

普通java工程的src/main/resources目录下的配置文件如何寻址

在src/main/java目录下的代码中如何访问src/main/resources目录下的配置文件?

Maven packs all the files and folders under main/resourcesinto the jar file at the the root

比如src/main/resources/config.xml,那么在代码中直接用“config.xml”就可以访问了。这个前提是,这是一个maven的项目。

原文地址:https://www.cnblogs.com/hustdc/p/10191971.html