在Maven中,main/resources和main/config有什么区别?
我想在我的Maven项目中放入一个配置文件.查看标准目录布局,有两个似乎很明智的地方,"src/main/resources
"和"src/main/config
".有人可以解释这两者之间的区别,并解释何时将某些内容放入config
和何时放入resources
吗?
I want to put a configuration file in my Maven project. Looking at the standard directory layout, there are two places that seem sensible, "src/main/resources
" and "src/main/config
". Could someone explain the difference between these, and explain when you would put something in config
and when in resources
?
在这种情况下,我正在查看的文件是ehcache.xml
,但是我的问题不是ehcache专用的,我很好奇log4j.properties
等.
In this case, the file I'm looking at is ehcache.xml
, but my question isn't ehcache specific, I'm curious for log4j.properties
etc.
发现了一些使用Google搜索功能的人此人有相同的问题,但是答案似乎矛盾,而且不太权威.
A bit of googling discovered this person had the same question, but the answers seemed contradictory, and not very authorative.
位于 http://www.mail-archive.com/users@maven.apache.org/msg90985.html 说:
"这全都是理论...也许在编写文档时,参与Maven开发的人认为拥有src/main/config目录可能很有用,因此它包含在文档中,但是由于它从来没有在代码中实现,今天不再使用."
和
"目录 [src/main/config] 未显示在类路径中,因此应用程序或测试类 无法读取其中的任何内容."
"The directory [src/main/config] doesn't show up on the classpath so the application or test classes can't read anything in it."
所以只需使用src/main/resources
.
注意:我不知道这是否是正确的(我是问问者),但这可以解释为什么网络上有那么多人推荐log4j.properties为src/main/resources
.如果人们同意这是正确的答案,您能告诉我(评论或投票)吗?我将其放在此处以免其他人打字.
Note: I don't know if this is true (I'm the question asker), but that would explain why so many people on the web recommend src/main/resources
for log4j.properties. If people agree this is the right answer could you let me know (comment or vote) I put it here to save other people the typing.