Project management four: Maven project management configuration

Recently, I often use Maven to manage projects, so I summarize the used Maven pom.xml configuration. The Maven version I use locally is apache-maven-3.0.3. The project is deployed in the form of a jar package for a common java application, and the configuration of the web project will be briefly introduced later.

1. Basic configuration

<!-- The pom.xml file takes project as the root node-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	
	<!-- Declare the versions supported by the pom.xml file-->
    <modelVersion>4.0.0</modelVersion>
	<!-- Global project unique identifier, usually using fully qualified package name to distinguish it from other projects -->
    <groupId>front</groupId>
	<!-- The unique product ID within the given groupId, which is also the output project name-->
    <artifactId>front</artifactId>
	<!-- The current version of the artifactId output by this project -->
    <version>1.0</version>
	<!-- output type: jar, war, ear... -->
    <packaging>jar</packaging>

2. Build configuration

<!-- Project local build file list, you can change the file build process-->
    <profiles>
        <profile>
	    <!-- Development environment configuration-->
            <id>dev</id>
	    <!-- Default execution development environment configuration-->
	    <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
		<!-- For each attribute configuration, use ${} placeholder directly in the configuration file-->
                <log.level>TRACE</log.level>
           	<!-- ... -->
            </properties>
        </profile>
        <profile>
	    <!-- Online environment configuration-->
            <id>prod</id>
            <properties>
                <log.level>DEBUG</log.level>
                <!-- ... -->
            </properties>
        </profile>
    </profiles>
How to use: mvn clean package -Pdev or -Pprod (execute a different build configuration) to package.

For details, please refer to my other blog:

Combining Commons Configuration and Maven for project configuration managementhttp:  //shensy.iteye.com/blog/1747408  

3. Constants

<!-- define some constants that can be used elsewhere in the project -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<!-- ... -->
    </properties>

4. Dependency Management

<!-- List of all dependencies of this project-->
  <dependencies>
    <dependency>
        <groupId>xxx</groupId>
        <artifactId>xxx</artifactId>
        <version>x.x.x</version>
        <scope>xx</scope>
    </dependency>
    <!-- ... -->
  </dependencies>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326969507&siteId=291194637