What is the advantage of the 'src/main/java'' convention?

前端 未结 5 1209
无人及你
无人及你 2020-12-04 11:51

I\'ve noticed that a lot of projects have the following structure:

  • Project-A
    • bin
    • lib
    • src
      • main
        • java
          • Ro
5条回答
  •  长情又很酷
    2020-12-04 12:28

    Others have already told you it's a Maven convention, I'm going to answer your question instead:

    Absolutely none. Certainly it's beneficial to separate pieces of code to separate root folders, but usually you could achieve the same with

    • [root]
      • src
        • com.org.net
          • Your.class
      • test
        • com.org.net
          • YourTest.class
      • lib
      • bin
      • resources

    instead. In fact here's a big thing Maven does that's actually hugely wrong: It wants to add binary content to source code repository which is meant for textual content only! All binary content should be managed outside the source code repository, that includes images in web applications and whatnot.

    But OK, lets assume that you've decided to live in the somewhat smelly Maven ecosystem; then you should of course follow the Maven conventions as strictly as possible.

提交回复
热议问题