The previous article learned about the MAVEN development environment, and manually wrote a mavenproject, but this is very inefficient. Today we are learning to build a MAVEN development environment under Eclipse.
Frequently used MAVEN commands
- MVN clean: Performs a cleanup operation that deletes data from the target directory
- MVN Clean Compile: Performs a cleanup operation before compiling the code into the target directory.
- MVN Clean test: Performing cleanup and testing
- MVN Clean Package: performing cleanup and packaging
- MVN clean install: Perform cleanup and installation. The packaged files are installed in the local repository so that other modules or projects can be configured to call the
- MVN Clean Deploy: Performs cleanup and advertisement, which is published to the private server.
Create a project using MVN archetype
Until now. We already know that the Java class is stored in the fixed path "Src/main/java" directory. The test class is stored in the "src/main/test" directory by default. It would be very troublesome to create these directories manually each time, but fortunately. MAVEN has provided us with a "maven archetype" to build the skeleton of the project.
This is the fixed directory and the Pom.xml file.
We create a new project "Test003", which is entered into the directory under the command line. Enter this command: "MVN archetype:generate", you can create a project.
The first time you create project you need to go to Maven's central repository to download something. It might be slower, and then you can see that when you use "MVN archetype:generate" to create project, you are prompted to enter some basic information about the project and what you need in the Pom.xml file:
GroupId
Artifactid
Package
Version
Be able to see the main required directories as well as the pom.xml files. MAVEN has been created for us on our own initiative.
Eclipse Configuration Maven Plugin
First you need to download the M2eclipse offline package. After the download is complete. Decompression has for example the following two directories:
Copy the appropriate file from the directory in the directory to the appropriate directory in the Eclipse installation directory, and then restart Eclipse. You can see the MAVEN option when you start clicking Window->preferences.
Configure your own Maven
Until now, you need to configure your downloaded Maven into eclipse.
Configure the location of the local warehouse
M2eclipse Offline Package
Eclipse builds MAVEN development environment