Review (1) "Maven"

Source: Internet
Author: User

Finally began to review the old knowledge, have input must have output. The internal process between input and output is particularly important, while reviewing, the real learning of the accumulation of things, deepen understanding.

    • Maven Project Concepts and configuration
  1. MAVEN is a project management and integration tool. MAVEN provides developers with a complete life cycle framework. The development team can automate the construction of the project's underlying tools, MAVEN uses the standard directory structure and the default build life cycle. Project build process: Clean, compile, test, package, integrate test, validate, deploy.
  2. There are three main building tools in the Java World: Ant, maven, and Gradle. After several years of development, Ant almost disappeared, Maven also died, and Gradle's development is at the zenith. For Android apps, it's recommended to use Gradle as a build tool, because Google's official push of Android studio uses Gradle as the native build tool, which allows Gradle to build support for Android versions of software. Gradle the largest two features. One is simplicity, and the compact script based on groovy is really addictive, and there is nothing unclear about the intent of the presentation. The second is flexible, all kinds of things in Maven difficult to do, in Gradle is a piece of cake, such as modifying the existing build life cycle, a few lines of configuration is complete, the same thing, in Maven you have to write a plug-in, Java programmer is familiar with XML, Using Gradle requires learning groovy and understanding the concept that its conventions are better than configuration.
  3. All the source code is placed in the folder/src/main/java/, all the unit test code is put into/src/test/java/, the page resource configuration code can be placed in/src/main/resources/. If you build your own, you need a build path to bring the folder up. Target is the file and directory where the project was built, the jar package, the war package, and the compiled class file. All of the content in target is generated when MAVEN builds.
  4. POM: Project Abstraction model

    This is the very core concept of maven. MAVEN uses it to manage projects. Each project has a pom.xml file that defines the basic information about the project, dependencies, etc., and Maven's lifecycle management of the project is also based on this file.

    GroupId: groups, companies, groups, organizations, projects, or other groups.

    Artifactid: A unique identifier that represents a single item under GroupId. The project name ID.

    Packaging: Identifies the type of project, such as Jar,war.

    Version: Revision number. The above 4 are the coordinates of Maven, they uniquely identify a project, and the configuration of dependent dependencies (dependency) is particularly important.

  5. Repository

    Warehouse, two-square library, three-party library concept. A default local repository and remote repository will be available whenever Maven is installed. When compiling, Maven looks for the local repository, and if the local repository does not, it will fetch the remote repository. Many companies use Nexus to build a database that is easy for all companies to download.

  6. Maven Common commands:
    1. Create a generic Java project for Maven:
    MVN archetype:create
    -dgroupid=packagename
    -dartifactid=projectname
    2. Create a MAVEN Web project:
    MVN archetype:create
    -dgroupid=packagename
    -dartifactid=webappname
    -darchetypeartifactid=maven-archetype-webapp
    3. Compiling source code: MVN Compile
    4. Compiling test code: MVN test-compile
    5. Run the test: MVN test
    6. Generate SITE:MVN Site
    7. Packaging: MVN Package
    8. Installing the JAR:MVN install in the local repository
    9. Clear the resulting project: MVN clean
    10. Build Eclipse Project: MVN eclipse:eclipse
    11. Generate the Idea project: MVN Idea:idea
    12. Combine with goal commands, such as package-only not tested: Mvn-dtest packages
    13. Compile the content of the test: MVN test-compile
    14. Only hit jar package: MVN Jar:jar
    15. Test without compiling and not compiling: mvn test-skipping compile-skipping Test-compile
    (-skipping's flexible use, of course, can also be used for other combination commands)
    16. Clear some system settings for Eclipse: mvn Eclipse:clean
  7. Attached directory structure:

Review (1) "Maven"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.