pom reference 笔记

来源:互联网 发布:网络童装代理 编辑:程序博客网 时间:2024/04/29 02:05

五个元素保证该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>

 

原创粉丝点击