MAVEN is a Java Project management tool in which all project configuration information is defined in a text called Pom.xml that covers the entire lifecycle of the project, including Project creation, compilation, testing, and publishing.
First, the preface
When you use Eclipse, you will find that you can import the MAVEN project directly,
Because the IDE defaults to the Maven plugin (I'm under the Java version)
But for a management tool, the use of the IDE is just easy to develop, and the command line is needed from a management standpoint.
Ii. installation of Maven
Maven command line installation method, very simple Baidu can search
Third, maven create command
1. Create command: Maven 3.0.5 version used the MVN archetype:generate,3.0.5 version before using MVN archetype:generate
Executes the Create Project command under a directory.
To create a Java project:
mvn archetype:generate -DgroupId=com.my.java.app -DartifactId=my-javaapp -DarchetypeArtifactId=maven-archetype-quickstart
To create a Web project:
mvn archetype:generate -DgroupId=com.my.web.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
Parameters:
GroupId: Total project name
Artifactid: Sub Project name
Archetypeartifactid: Use the template for the project, each template will create a corresponding directory structure and some common files
Under the project directory:
MVN compile: Compiling source code
MVN Clean: Clear compilation file (target directory was killed)
MVN test-compile: Compiling test code
MVN test: Run Tests in Directory
MVN package: Compiles, tests, packs, and the current project's jar pack is placed under the target directory
MVN install: Compiles, tests, packs, and stores the jar package for the current project into the local repository
Iv. the concept of the warehouse
In Maven, there are two warehouses of local and central libraries. The central repository defaults to the common library provided by the Apache site, where the local repository downloads the jar packages that need to be relied on locally.
The local library can be configured in the Conf/settings.xml under the MAVEN installation directory.
You can use Nexus to build a central library in your company. Through the intranet to access the company project depends on the jar package.
D:. ├─my-javaapp│ │ pom.xml│ ││ ├─src│ │ ├─main│ │ │ └─java│ │ │ └─com│ │ │ └─my│ │ │ └─java│ │ │ └─app│ │ │ app.java│ │ ││ │ └─test│ │ └─java│ │ └─com│ │ └─my│ │ └─java│ │ └─app│ │ apptest.java│ ││ └─target
Pom.xml:Maven Core Files
Src/main/java: Source code path
Src/test/java: Test code path
Target: Compiled class file or package file path
Src/main/resources: (optional) configuration file path