POM Configuration
Table of Contents
See example POM Configuration.
1 Identify our project
Fully qualified name of project is “<groupId>:<artifactId>:<version>”. If groupId is a domain, it will be transformed into directory path while downloading. Download something with groupId=org.X.A from url.com will download things from url.com/org/X/A in the end.
2 Inheritance
When we have two projects, A and B, A is supposed to be parent
project of B. You have to specify the pom.xml of project B to
indicate that the parent of B is A with the groupId,
artifactId and version of A. You can remove the groupId and
version of B to make A and B have the same /groupId and
version. One can also indicate the <relativePath>
for parent
project to put the A and B in the same directory level.
B inherite the dependencies from A.所以parent用来继承POM,dependency 用来解决代码依赖. parent的项目在代码上没有关系.
The packages downloaded by maven are put under HOME.m2/repository/.
所有 POM.xml 里面的元素都可以用 ${project.A.B.C}
的方式进行引用.比
方说如果在 XML 根路径下有这样的结构
<A><B>lalala<C>blabla<C/></B></A>
, ${project.A.B.C}
就等于
blabla
.
3 Tasks
首先,maven可以使用一系列的plugin来支持各种功能,包括发布,运行测试等
等.在使用 spring-boot-maven-plugin
的时候,可以用 mvn
spring-boot:run
来运行程序. spring-boot
应该是plugin的名字, run
则是定义好的task. 在使用 maven-scala-plugin
的时候,如果加入以下设
置
<executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions>
运行 mvn scala:testCompile
则只会编译test部分的代码.