Maven Common
Project Object Model
XML Schema
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
</project>
Basic Archetype
<!-- The Basics -->
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>...</packaging>
<dependencies>...</dependencies>
<parent>...</parent>
<dependencyManagement>...</dependencyManagement>
<modules>...</modules>
<properties>...</properties>
<!-- Build Settings -->
<build>...</build>
<reporting>...</reporting>
<!-- More Project Information -->
<name>...</name>
<description>...</description>
<developers>...</developers>
<contributors>...</contributors>
<!-- Environment Settings -->
<prerequisites>...</prerequisites>
<repositories>...</repositories>
<pluginRepositories>...</pluginRepositories>
<distributionManagement>...</distributionManagement>
<profiles>...</profiles>
Java Version & Source Encoding
这篇文章讲述输入配置 Maven 项目的 Java 版本:https://www.baeldung.com/maven-java-version
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Resource Direction
Maven 默认只在 resource phase 将 maven 项目/src/main/resource
和 maven 项目/src/test/resource
下的文件复制过滤到 target/classes 中,有时需要在 /src/main/java
中放置静态资源,但这些资源默认在 build 后不可访问,可以通过如下设置进行复制:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
<build>
<testResources>
<testResource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResource>
</build>
Maven Convention
Maven Standard Directory Layout
src/main/java |
Application/Library sources |
---|---|
src/main/resources |
Application/Library resources |
src/main/filters |
Resource filter files |
src/main/webapp |
Web application sources |
src/test/java |
Test sources |
src/test/resources |
Test resources |
src/test/filters |
Test resource filter files |
src/it |
Integration Tests (primarily for plugins) |
src/assembly |
Assembly descriptors |
src/site |
Site |
LICENSE.txt |
Project's license |
NOTICE.txt |
Notices and attributions required by libraries that the project depends on |
README.txt |
Project's readme |
具体描述见官网。
标签:...,Maven,java,src,maven,common,main,resources From: https://www.cnblogs.com/locustree/p/17153507.html