----- maven actual reading notes

Chapter VI Maven repository

1. Classification warehouse: warehouse into the local repository, a remote warehouse, central warehouse, PW.

Local repository: maven repository on the machine, the local repository configuration Setting path, as shown below, downloaded jar packets are stored in D: \ java \ repository in.

Remote repository: local repository like the library, when you want to read a book, will first look in the local warehouse there are not, and if not, go to the bookstore to buy a remote repository like this bookstore when I want to read to buy after the book, it will save in the study, under the recall reading this book, you go directly to the library to find, only a local repository, but you can configure multiple remote repository.
Central warehouse: maven will default to a remote repository available, no need to configure, maven will automatically identify the warehouse, the warehouse is the central repository.

PW: PW is a special remote warehouse, he was set up warehouses in the LAN, WAN proxy PW remote repository for maven LAN users to use when you need to download maven dependent jar package, he will ask PW, PW is not present if he would go outside of the remote repository to download, the download is complete store to PW, the next time the request is PW, in addition, we can also rely on some of the public service as a uploaded to PW, the project when people use multiple teams, you do not need to copy each other, can be downloaded directly, the advantage of saving his own broadband outside the network, accelerating maven build, deploy third-party plug-ins (that is, only opening up public services, belonging to the company dependent on their business jar), improved stability, enhanced control and reduced load on the central warehouse.

2. remote repository configuration, when the central warehouse can not meet the needs of the project, the project may need to rely on another remote repository, the JBoss Maven repository, then, you can configure the warehouse in the POM.

In repositories, you can declare one or more remote repository, in this example, declare an id to jboss, named JBoss Repository warehouse, a warehouse declared any id must be unique, maven's own central warehouse use id is central, if other warehouses also affirmed the use of the id, the configuration of the central warehouse will be covered by this configuration, releases and snapshots more important, they are used to control the release version for download maven snapshots member and member of the example in realeases the enable is true, expressed support for the download release supports JBoss warehouse, snapshots to false, indicating SNAPOFF Download JBoss support the warehouse, according to the configuration, maven will only download the release from the JBoss warehouse components, without It will download the snapshot version of the component. Value layout is default, a layout is the default layout of the warehouse maven2 and maven3 instead maven1, for releases and snapshots, he has another two children, updatePolicy and checksumPolicy, updatePolicy on behalf of the update frequency, default daily once a day , never to never check for updates, always is inspected once every build, interval: X represents every X check for updates once. ChecksumPolicy elements used to configure a policy file checksum and maven, maven when the member is deployed to the warehouse, will deploy the corresponding checksum files when downloading member, maven verifies the checksum and file verification fails when when, in order to warn, maven will be output when setting values ​​checksumPolicy when performing component warnings, fail, maven let the build fails checksum error is encountered, ignore, ignore completely the maven checksum error.

3. remote repository certification

Most remote repository can be accessed without authentication, sometimes completely out of consideration, the need to provide authentication information before they can access some of the remote repository, such as PW.

4. Deploy to a remote repository

PW a major role in the deployment of third-party documents, including internal organization generated artifacts and some components can not be obtained directly from the outside of the warehouse, which means we need to deploy to the PW, for other team members to use, edit the project pom.xml, configuration is as follows, which noted that the id should setting.xml in a server id of the same elements, and the user name and password are required to match correctly.

Upload command: mvn clean deploy, maven project will be deployed to build output components corresponding to the configuration of the remote repository, if the current version is a snapshot version of the project, it will be deployed to the snapshot version of the address of the warehouse, otherwise they will be deployed to the release version of the warehouse address , the following chart is a snapshot of deploying a version of the output:

5. snapshot version

Such a configuration is a snapshot version of a snapshot version is unstable semi-mature product, when the development of stable, will change the 1.0.0 version, at this time becomes a release.

6. Mirror

All contents if the mirror X can provide warehouse Y stored for so long can be considered X is a mirror image of Y, common usage mirroring is with PW use, due to the PW can represent any external public warehouses, including a central warehouse for the internal organization and words, using a PW address is equivalent to the use of all the required external repository may be configured to focus PW, simplifying maven configuration, as shown, it is a maven PW configuration.

 

 

Chapter VII of the Maven lifecycle and plug-ins

1.Maven life cycle is to be abstract and unified all of the build process, maven learn a lot from the project and build tools and reflection, summed up a set of highly sophisticated and easy to extend the life cycle of the project life cycle contains the clean-up, initialization, compile, test, package, integration testing, validation, deployment and site generates almost all build steps.

maven life cycle is abstract, meaning that the life cycle of itself without any actual work in the design maven, the actual tasks (such as compiling source code) by the plug-in to complete this idea and design patterns templates a similar pattern, the template method defines an overall configuration algorithm in the parent class, a subclass can be controlled by the actual behavior override the parent class implementation, the algorithm ensures that sufficient scalability, there can be tightly controlled overall configuration algorithm . , Follows the template can well embody the concept of life cycle maven:

这段代码非常简单,build()方法定义了整个构建的过程,依次是初始化,编译,测似,打包(由于package与java关键字冲突,这里使用了单词packagee),集成测试,部署,但是这个类并没有具体现实初始化,编译,打包,集成测试,部署,由子类去实现。

2.三套生命周期

初学者往往以为Maven的生命周期是一个整体,Maven拥有三套相互独立的生命周期,他们分别是clean,default,site,clean生命周期的目的是清除项目,default生命周期的目的是构建项目,而site生命周期的目的是建立项目站点。

 

3.命令行与生命周期

4.插件目标

5.插件绑定

 

Guess you like

Origin www.cnblogs.com/hejj-bk/p/11419769.html