The Convention of development principle is greater than configuration

Source: Internet
Author: User

In the development process, the principle of "Convention is greater than configuration" is used everywhere, even the team development norm, the development compiles the environment and so on also wants everybody to implement. Taking Java construction as an example, from Ant to Maven to Gradle, it is better and more to realize the idea of "convention is greater than configuration". In the Ant and bat era, it is often important to write or modify scripts for each project, even if the project's main directory structure is reflected in the code. By the time of Maven, many things were simplified through conventions:The directory where the Pom.xml is located should be the root of the project, assuming the directory is ${proj-dir}, then Maven has the following assumptions:
    • ${proj-dir}/src/main/java--the. java file that holds the project.
    • ${proj-dir}/src/main/resources-- Store project resource files, such as spring, hibernate configuration files.
    • ${proj-dir}/src/test/jave-- Store all test. java files, such as JUnit test classes.
    • ${proj-dir}/src/test/resources-- Test the resource file.
    • ${proj-dir}/target--project output location.

Run a MVN clean Package command, MAVEN will help you clear the target directory, re-build an empty, compile Src/main/java class to target/classes, copy src/main/ Resources files to target/classes, compiling Src/test/java to target/test-classes, copying src/test/resources files to target/test-classes ; then run all the tests; After the test passes, it is packaged with the jar command and stored in the target directory. Maven does a lot of things, but all the users are hidden, it only requires you to follow its convention.

The Gradle, which is now becoming popular, simplifies MAVEN-related configuration. such as the introduction of hibernate dependency

Using Maven

<dependency><groupId>Org.hibernate</groupId><artifactid>Hibernate-core</artifactid><version>4.3.6.Final</version></Dependency>

Use Gradle only one line

org.hibernate:hibernate-core:4.3.6.Final



From for notes (Wiz)

The Convention of development principle is greater than configuration

Related Article

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.