在Maven中,main/resources和main/config有什么区别? [英] In maven, what is the difference between main/resources and main/config?

查看:329
本文介绍了在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.

这篇关于在Maven中,main/resources和main/config有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆