Maven dependency scope, usescopeSaid.

  • The scope of value havecompile.test.providedThe default iscompile
  • Scope: Indicates the scope of dependency usage, which is at work in those phases of a Maven build project.
  • Maven build project compilation, testing, packaging, installation, and deployment processes (phases)
  • junitThe dependency range oftest
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
  <scope>test</scope>
</dependency>
Copy the code

Maven common Settings

The global variable

  • In the Mavenpom.xmlFile,<properties>Used to define global variables, passed in POM${property_name}References the value of a variable in the form of.
  • Define global variables:
<properties>
	<spring.version>4.3.10. RELEASE</spring.version>
</properties>
Copy the code
  • Reference global variables:
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-context</artifactId>
	<version>${spring.version}</version>
</dependency>
Copy the code
  • Variables used by the Maven system:
<properties>
	 <maven.compiler.source>1.8</maven.compiler.source>Source compiler JDK version<maven.compiler.target>1.8</maven.compiler.target>The JDK version of the code to run<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>Project construction using the code, to avoid Chinese garbled code<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>Generate the code for the report</properties>
Copy the code

Specify resource location

  • src/main/javasrc/test/javaAll of these directories*.javaThe files will be located separatelycomiletest-comiplePhases are compiled, and the compilation results are placed separatelytarget/classestarge/test-classesDirectory, but other files in both directories will be ignoredsrcDirectory to the file packagetarget/classesDirectory, as outputjarPart of it. The resource file location needs to be specified. The following content is placed<buid>Tag.
<build>
	<resources>
		 <resource>
		 <directory>src/main/java</directory>Directory where<includes>Including.properties,.xml files in the directory<include>**/*.properties</include>
			 <include>**/*.xml</include>
		 </includes>Filtering option False Do not enable filters, *. Property already acts as a filter<filtering>false</filtering>
		 </resource>
	 </resources>
</build>
Copy the code