pom reference 筆記

五個元素保證該maven 元素不同於其他元素

  • groupId: This is generally unique amongst an organization or a project. 
  • artifactId:The artifactId is generally the name that the project is known by
  • version:This is the last piece of the naming puzzle. 
  • packaging:project's artifact typ.maybe one of pomjarmaven-pluginejbwarearrarpar ,default jar
  • classifier:not necessary.主要用戶區分由同一個pom衍生出來的不同artifact(project),主要用在一下兩個場景:

1. As a motivation for this element, consider for example a project that offers an artifact targeting JRE 1.5 but at the same time also an artifact that still supports JRE 1.4. The first artifact could be equipped with the classifier jdk15 and the second one with jdk14 such that clients can choose which one to use.

2.  Another common use case for classifiers is the need to attach secondary artifacts to the project's main artifact. If you browse the Maven central repository, you will notice that the classifiers sources andjavadoc are used to deploy the project source code and API docs along with the packaged class files.


<denpendencies></denpendencies>依賴關係配置

 

 

對於配置的依賴,如果無法從maven 中央倉庫中獲取,那麼可以使用一下三種方式:

  1. Install the dependency locally using the install plugin. The method is the simplest recommended method. For example:mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -DartifactId=non-maven-proj -Dversion=1 -Dpackaging=jar

    Notice that an address is still required, only this time you use the command line and the install plugin will create a POM for you with the given address.

    即下載到本地並使用install 插件加入

  2. Create your own repository and deploy it there. This is a favorite method for companies with an intranet and need to be able to keep everyone in synch. There is a Maven goal called deploy:deploy-filewhich is similar to the install:install-file goal (read the plugin's goal page for more information).創建本地倉庫,並導入
  3. Set the dependency scope to system and define a systemPath. This is not recommended.使用本地資源,不去倉庫獲取(都脫離了maven的控制了,當然不推薦了)

<scope></scope>:依賴文件發生作用的範圍
This element refers to the classpath of the task at hand (compiling and runtime, testing, etc.) as well as how to limit the transitivity of a depedency. There are five scopes available:

  • compile - this is the default scope, used if none is specified. Compile dependencies are available in all classpaths. Furthermore, those dependencies are propagated to dependent projects.
  • provided - this is much like compile, but indicates you expect the JDK or a container to provide it at runtime. It is only available on the compilation and test classpath, and is not transitive.
  • runtime - this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • test - this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
  • system - this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.(本地資源)

<systemPath></systemPath>:定義本地資源路徑,僅僅在<scope>system</scope>的時候使用,必須是絕對地址,但推薦使用${java.home}/lib形式的路徑(參見properties)

<optional></optional>:當該pom代表的artifact本省就是一個dependency時,告訴其他依賴者我,沒有他們我也能正常工作。

 

 

 

 

 

告訴maven,這個dependency依賴的子dependency我不需要,可以定義多個<exclusion></exclusion>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章