Maven dependency scope, usescope
Said.
- The scope of value have
compile
.test
.provided
The 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)
junit
The 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 Maven
pom.xml
File,<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/java
和src/test/java
All of these directories*.java
The files will be located separatelycomile
和test-comiple
Phases are compiled, and the compilation results are placed separatelytarget/classes
和targe/test-classes
Directory, but other files in both directories will be ignoredsrc
Directory to the file packagetarget/classes
Directory, as outputjar
Part 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