1. Maven is valid
Maven is a project management tool, comprising a project object model (POM), a set of standards, a project life cycle (the Lifecycle), a dependency management system, and used to define the plug of the target logical operation lifecycle stage .
2. Maven can solve any kind of problem
(1) to resolve the conflict jar package
(2) compiled code
(3) convenient unit testing
(4) packaging projects, generate reports
(5) deployment project to generate site
3. Dependency Management
Simply put, rely on Maven project management process management is to jar package
the difference:
Traditional Web project: jar package stored in a project, greatly take up disk space
Maven Web project: jar package does not put the project, but by "coordinate" search using the jar in a unified package repository, code reuse concept of development
(Jar package because the warehouse is great, one of the two projects fail to reflect the advantages of Maven, will reflect the size advantage when only encountered a large number of projects)
4. Construction of a key item
Step build: compile, test, run, packaging, installation and deployment
By all steps to harmonize to Maven, do a key project to build
Maven build process standardization
Clean up, compile, test, report, package, deploy
5. Maven repository
Maven project because there is no storage jar package, which only coordinate with the jar package. Use the jar package when you have to find the corresponding jar package according to the coordinates of the Maven repository.
Maven repository is divided into
Local repository: When installing Maven, Maven disk will automatically C / User / current user directory arrangement /.m2/repository local repository, the local repository path may be provided manually.
Central warehouse: Almost all open source jar apache package provided warehouse.
Remote repository: the case of non-networked enterprises can also download jar package warehouse, warehouse housed in private enterprise database.
relationship:
Local warehouse: jar package provides project used the jar package can be obtained from a remote warehouse and central warehouse, and personal jar package can be uploaded to a remote repository.
Central warehouse: provide almost all open source packages for local warehouse jar and remote repository.
Remote Storage: Provide local warehouse jar package, also available from the local repository (local warehouse need to manually upload) and central warehouse acquire jar package.
6. Maven project structure
Maven code is divided into two major parts, the core part and test part into the test core and spaced apart, to facilitate the development and testing
src / main / java: core code
src / main / resources: Profiles
src / test / java: test code
src / test / resources: Test Profile
src / main / webapp: web development directories, storage resource page
7. Maven common commands
mvn clean: clean-up projects generated by the compiler file, delete the target folder
mvn compile: compile under src / main directory code generation target folder to store the project file compiled
mvn test: under the code compiled src / main and src / test directory
mvn package: at compile src / main and src / test directory code, and project package
(File format can be provided in packaged <packaging> tag pom.xml project file)
mvn install: compile under src / main and src / test directory code, and project package, the installation package to a local warehouse
mvn tomcat: run: After the project is generated compiler package comes loaded into Maven's Tomcat
8. Maven life cycle
Maven project five important steps: cleaning, compile, test, package, installation, release
"Clean up" after the clean-up as life-cycle independent of the composition of the five default life cycle of existence
The default life cycle: To complete the test had to be compiled; steps in order to complete the package would first have to be built, tested two areas, the rest of empathy
9. Maven conceptual model
Maven's two major characteristics: dependency management, a key building
(1) Dependency Management
Dependency management is divided into project object model and dependency management model
Project Object Model: The core is the project pom.xml files, file records with the project's own information, jar package information use, project execution environment information
Dependency management model: the coordinates and warehouse jar package composition, coordinates the project name from the jar package, module name, version, and relies range (jar package to prevent conflict)
(2) Construction of a key
Maven life cycle depends on the characteristics of each step will rely on a plug-in to complete the underlying Maven finalizing a function key Construction