When the command line using the attribute is -D, for example: mvn -Dinput = test
Cited official description https://maven.apache.org/pom.html#Properties :
Properties
POM property is to understand the basics of the last element. Maven attribute value is a placeholder, such as the properties in Ant. Their values by using the symbol $ {X} to access any location in the POM, wherein X is an attribute.
They have five different styles:
1, env.X : use the "env" to define variables. We will return the shell environment variables. For example, $ {} env.PATH comprising PATH environment variable.
Note: Although the environment variable itself is not case sensitive on Windows, but look for a property case sensitive. In other words, although the Windows shell is % PATH% and % Path% return the same value, but the distinction Maven $ {env.PATH} and $ {} env.Path . For Maven 2.1.0, for reliability, the name of the environment variable is normalized to all uppercase .
2, project.x : (.) Point marks the POM path will contain a value of the corresponding element. For example: by $ {project.version} Access <Project> <Version> 1.0 </ Version> </ Project> .
. 3, settings.x : the settings.xml (.) In the path point label will contain the value of the corresponding element. For example: <Settings> <Offline> to false </ Offline> </ Settings> by {settings.offline} $ access.
. 4, the Java system properties : by () java.lang.System.getProperties all attributes can be used as POM access attributes, such as $ {} the java.home .
. 5, X : in the POM <properties /> element is provided. <properties> <someVar> value < / someVar> </ properties> value may be used as $ {} someVar .
And when pom.xml file access attributes in the second point, in fact, there are some built-in variables, as follows:
project.basedir} {$ : This referenced module / project root of the folder (current position pom.xml file is located), the wording can be simplified: $ {basedir}
More than usage Reference: http://maven.apache.org/ref/3.5.0/maven-model-builder/#Model_Interpolation
project.build.directory} {$ : This indicates the default target folder.
project.build.outputDirectory} {$ : represents default target / classes folder.
project.build.testOutputDirectory} {$ : This represents the default target / test-classes folder.
project.build.sourceDirectory} {$ : this means that by default src / main / java folder.
project.build.testSourceDirectory} {$ : this means that by default src / test / java folder.
$ {project.build.finalName} is defined as the default: $ project.artifactId} {-} $ {project.version .
project.version} {$ : You can use this position must be written in text version. Otherwise, especially if you are among the building blocks in a multi-module dependencies.
More than usage Reference: http://maven.apache.org/pom.html#The_Super_POM
settings.localRepository} {$ : it refers to the location of the local repository. This is the default $ {Home} /. M2 / Repository .
More than usage Reference: http://maven.apache.org/pom.html#Properties
Above reference: https://cwiki.apache.org/confluence/display/MAVEN/Maven+Properties+Guide
And for the first time 5:00 should be the most used on the project, such as the practice of simple pom.xml for the project:
<?xml version="1.0" encoding="UTF-8"?> <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"> <modelVersion>4.0.0</modelVersion> <groupId>com.jsoft.test</groupId> <artifactId>test-maven</artifactId> <version>1.0-SNAPSHOT</version> <profiles></profiles> <properties> <test.uuid>123</test.uuid> <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName> <jdbc.url>jdbc:mysql://localhost/stock?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&autoReconnect=true</jdbc.url> <jdbc.username>root</jdbc.username> <jdbc.password>123456</jdbc.password> <jdbc.validationQuery>SELECT 1 + 1</jdbc.validationQuery> </properties> <build> <resources> <resource> <filtering>true</filtering> <directory>${project.basedir}/src/main/resources/${test.uuid}</directory> <includes> <include>*.properties</include> </includes> </resource> </resources> </build> </project>
As can be seen in the properties as long as the node is configured to use custom properties anywhere, such as in the form of $ {x}.
Of course, except for using the custom properties in the pom.xml, the properties file may also be used, such as the project file src / main / resources / jdbc.properties file is written as follows:
jdbc.driverClassName=${jdbc.driverClassName} jdbc.url=${jdbc.url} jdbc.username=${jdbc.username} jdbc.password=${jdbc.password} jdbc.validationQuery=${jdbc.validationQuery}
When the command line using the attribute is -D, for example: mvn -Dinput = test
Cited official description https://maven.apache.org/pom.html#Properties :
Properties
POM property is to understand the basics of the last element. Maven attribute value is a placeholder, such as the properties in Ant. Their values by using the symbol $ {X} to access any location in the POM, wherein X is an attribute.
They have five different styles:
1, env.X : use the "env" to define variables. We will return the shell environment variables. For example, $ {} env.PATH comprising PATH environment variable.
Note: Although the environment variable itself is not case sensitive on Windows, but look for a property case sensitive. In other words, although the Windows shell is % PATH% and % Path% return the same value, but the distinction Maven $ {env.PATH} and $ {} env.Path . For Maven 2.1.0, for reliability, the name of the environment variable is normalized to all uppercase .
2, project.x : (.) Point marks the POM path will contain a value of the corresponding element. For example: by $ {project.version} Access <Project> <Version> 1.0 </ Version> </ Project> .
. 3, settings.x : the settings.xml (.) In the path point label will contain the value of the corresponding element. For example: <Settings> <Offline> to false </ Offline> </ Settings> by {settings.offline} $ access.
. 4, the Java system properties : by () java.lang.System.getProperties all attributes can be used as POM access attributes, such as $ {} the java.home .
. 5, X : in the POM <properties /> element is provided. <properties> <someVar> value < / someVar> </ properties> value may be used as $ {} someVar .
And when pom.xml file access attributes in the second point, in fact, there are some built-in variables, as follows:
project.basedir} {$ : This referenced module / project root of the folder (current position pom.xml file is located), the wording can be simplified: $ {basedir}
More than usage Reference: http://maven.apache.org/ref/3.5.0/maven-model-builder/#Model_Interpolation
project.build.directory} {$ : This indicates the default target folder.
project.build.outputDirectory} {$ : represents default target / classes folder.
project.build.testOutputDirectory} {$ : This represents the default target / test-classes folder.
project.build.sourceDirectory} {$ : this means that by default src / main / java folder.
project.build.testSourceDirectory} {$ : this means that by default src / test / java folder.
$ {project.build.finalName} is defined as the default: $ project.artifactId} {-} $ {project.version .
project.version} {$ : You can use this position must be written in text version. Otherwise, especially if you are among the building blocks in a multi-module dependencies.
More than usage Reference: http://maven.apache.org/pom.html#The_Super_POM
settings.localRepository} {$ : it refers to the location of the local repository. This is the default $ {Home} /. M2 / Repository .
More than usage Reference: http://maven.apache.org/pom.html#Properties
Above reference: https://cwiki.apache.org/confluence/display/MAVEN/Maven+Properties+Guide
And for the first time 5:00 should be the most used on the project, such as the practice of simple pom.xml for the project:
<?xml version="1.0" encoding="UTF-8"?> <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"> <modelVersion>4.0.0</modelVersion> <groupId>com.jsoft.test</groupId> <artifactId>test-maven</artifactId> <version>1.0-SNAPSHOT</version> <profiles></profiles> <properties> <test.uuid>123</test.uuid> <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName> <jdbc.url>jdbc:mysql://localhost/stock?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&autoReconnect=true</jdbc.url> <jdbc.username>root</jdbc.username> <jdbc.password>123456</jdbc.password> <jdbc.validationQuery>SELECT 1 + 1</jdbc.validationQuery> </properties> <build> <resources> <resource> <filtering>true</filtering> <directory>${project.basedir}/src/main/resources/${test.uuid}</directory> <includes> <include>*.properties</include> </includes> </resource> </resources> </build> </project>
As can be seen in the properties as long as the node is configured to use custom properties anywhere, such as in the form of $ {x}.
Of course, except for using the custom properties in the pom.xml, the properties file may also be used, such as the project file src / main / resources / jdbc.properties file is written as follows:
jdbc.driverClassName=${jdbc.driverClassName} jdbc.url=${jdbc.url} jdbc.username=${jdbc.username} jdbc.password=${jdbc.password} jdbc.validationQuery=${jdbc.validationQuery}