MAVEN项目标准目录结构 ;
http://blog.csdn.net/lengyue_wy/article/details/6718637
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
1.標準目錄結構:src
? -main ????? –bin 腳本庫 ????? –java java源代碼文件 ????? –resources 資源庫,會自動復制到classes目錄里 ????? –filters 資源過濾文件 ????? –assembly 組件的描述配置(如何打包) ????? –config 配置文件 ????? – webapp web應用的目錄。WEB-INF、css、js等 ? -test ????? –java 單元測試java源代碼文件 ????? –resources 測試需要用的資源庫 ????? –filters 測試資源過濾庫 ? -site Site(一些文檔) target LICENSE.txt Project’s license README.txt Project’s readme工程根目錄下就只有src和target兩個目錄
target是有存放項目構建后的文件和目錄,jar包、war包、編譯的class文件等。
target里的所有內容都是maven構建的時候生成的
參照:http://breath.iteye.com/blog/1005447
++++++++++++++++++++++++++++++++++++++++++++
Maven項目的標準目錄介紹
?
Maven提倡使用一個共同的標準目錄結構,使開發人員能在熟悉了一個Maven工程后,對其他的Maven工程也能清晰了解。這樣做也省去了很多設置的麻煩。
以下的文檔介紹是Maven希望的目錄結構,并且也是目錄創建工程是采用的目錄結構。Maven推薦大家盡可能的遵守這樣的目錄結構。
| src/main/Java | Application/Library sources |
| src/main/resources | Application/Library resources |
| src/main/filters | Resource filter files |
| src/main/assembly | Assembly descriptors |
| src/main/config | Configuration files |
| src/main/webapps | Web application sources |
| src/test/java | Test sources |
| src/test/resources | Test resources |
| src/test/filters | Test resource filter files |
| src/site | Site |
| LICENSE.txt | Project's license |
| README.txt | Project's readme |
在頂級目錄上是工程的描述文件pom.xml(如果使用Ant則還包括其他屬性文件,maven.xml或build.xml),另外還包括提供給最終用戶的文件,如,README.txt,LICENSE.txt等等。
?
頂級目錄還包括兩個子目錄:src,target。頂級目錄下可能出現的其他目錄僅僅是CVS或.svn和其他多模塊工程的工程目錄,最好不要再有其他目錄。
?
Target目錄是所有工程編譯構建的輸出目錄。
?
Src目錄包含所有工程的源碼文件,配置文件,資源文件等等。它下面的子目錄一般包含main(主要的工程源文件),test(測試文件),site(項目站點文件)。
?
項目構建的生命周期的介紹
?
Maven 2是圍繞著構建生命周期概念設計的。這意味著,構建或者發布的過程已經被清晰的定義了。
當我們使用Maven構建工程時,我們只需要了解幾個Maven定義好的命令即可,其他的工作則交給POM來完成。
以下給出Maven提供的構建生命周期列表:
| validate | validate the project is correct and all necessary information is available. |
| generate-sources | generate any source code for inclusion in compilation. |
| process-sources | process the source code, for example to filter any values. |
| generate-resources | generate resources for inclusion in the package. |
| process-resources | copy and process the resources into the destination directory, ready for packaging. |
| compile | compile the source code of the project. |
| process-classes | post-process the generated files from compilation, for example to do bytecode enhancement on?Java?classes. |
| generate-test-sources | generate any test source code for inclusion in compilation. |
| process-test-sources | process the test source code, for example to filter any values. |
| generate-test-resources | create resources for testing. |
| process-test-resources | copy and process the resources into the test destination directory. |
| test-compile | compile the test source code into the test destination directory |
| test | run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed. |
| package | take the compiled code and package it in its distributable format, such as a JAR. |
| pre-integration-test | perform actions required before integration tests are executed. This may involve things such as setting up the required environment. |
| integration-test | process and deploy the package if necessary into an environment where integration tests can be run. |
| post-integration-test | perform actions required after integration tests have been executed. This may including cleaning up the environment. |
| verify | run any checks to verify the package is valid and meets quality criteria. |
| install | install the package into the local repository, for use as a dependency in other projects locally. |
| deploy | done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. |
因此,當我們構建一個項目時,只需要了解自己希望做什么,然后執行以上對應的生命周期即可。
?
例如,我們希望編譯我們的工程。在命令行狀態下進入到工程的pom.xml文件所在的目錄中,使用命令:mvn compile;希望構建打包我們的工程,使用mvn package即可。
?
當然了,maven的構建生命周期也是可以擴展和自定義的,這里就先不做介紹了。
?
參照:http://hi.baidu.com/mylovechangchu/blog/item/fbda36da3644a6dfb6fd48d6.html
+++++++++++++++++++++++++++++++
APACHE原址:http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
轉載于:https://www.cnblogs.com/linbo3168/p/6541250.html
總結
以上是生活随笔為你收集整理的MAVEN项目标准目录结构 ;的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]Linux系统下yum和apt-g
- 下一篇: 紫书搜索 例题7-10 UVA - 11