下面是一个比较全面的 POM 文件的结构,当然常用的并不需要这么多配置,视自己的项目需求而定。

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  3. http://maven.apache.org/maven-v4_0_0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <!-- groupId:项目或者组织的唯一标志,并且配置时生成的路径也是由此生成, 如com.mycompany.app生成的相对路径为:/com/mycompany/app -->
  6. <groupId>asia.banseon</groupId>
  7. <!-- artifactId: 项目的通用名称 -->
  8. <artifactId>banseon-maven2</artifactId>
  9. <!-- packaging: 打包的机制,如pom, jar, maven-plugin, ejb, war, ear, rar, par -->
  10. <packaging>jar</packaging>
  11. <!-- version:项目的版本 -->
  12. <version>1.0-SNAPSHOT</version>
  13.  
  14. <!--父项目 -->
  15. <parent>
  16. <groupId>com.ylink</groupId>
  17. <artifactId>parent</artifactId>
  18. <version>1.3</version>
  19. </parent>
  20.  
  21. <!-- 项目的名称, Maven产生的文档用 -->
  22. <name>banseon-maven</name>
  23. <!-- 从哪个网站可以找到这个项目,提示如果Maven资源列表没有,可以直接上该网站寻找,Maven产生的文档用 -->
  24. <url>http://www.baidu.com/banseon</url>
  25. <!-- 项目的描述, Maven 产生的文档用 -->
  26. <description>A maven project to study maven.</description>
  27.  
  28. <!-- 开发者信息 -->
  29. <developers>
  30. <developer>
  31. <id>HELLO WORLD</id>
  32. <name>banseon</name>
  33. <email>banseon@126.com</email>
  34. <roles>
  35. <role>Project Manager</role>
  36. <role>Architect</role>
  37. </roles>
  38. <organization>demo</organization>
  39. <organizationUrl>http://hi.baidu.com/banseon</organizationUrl>
  40. <properties>
  41. <dept>No</dept>
  42. </properties>
  43. <timezone>-5</timezone>
  44. </developer>
  45. </developers>
  46. <!-- 类似 developers -->
  47. <contributors></contributors>
  48. <!-- 本项目相关 mail list,用于订阅等信息 -->
  49. <mailingLists>
  50. <mailingList>
  51. <name>Demo</name>
  52. <!-- Link mail -->
  53. <post>banseon@126.com</post>
  54. <!-- mail for subscribe the project -->
  55. <subscribe>banseon@126.com</subscribe>
  56. <!-- mail for unsubscribe the project -->
  57. <unsubscribe>banseon@126.com</unsubscribe>
  58. <archive>
  59. http:/hi.baidu.com/banseon/demo/dev/
  60. </archive>
  61. </mailingList>
  62. </mailingLists>
  63. <!-- 项目的问题管理系统(Bugzilla,Jira,Scarab,或任何你喜欢的问题管理系统)的名称和URL,本例为 jira -->
  64. <issueManagement>
  65. <system>jira</system>
  66. <url>http://jira.baidu.com/banseon</url>
  67. </issueManagement>
  68. <!-- organization information -->
  69. <organization>
  70. <name>demo</name>
  71. <url>http://www.baidu.com/banseon</url>
  72. </organization>
  73. <!-- License -->
  74. <licenses>
  75. <license>
  76. <name>Apache 2</name>
  77. <url>http://www.baidu.com/banseon/LICENSE-2.0.txt</url>
  78. <distribution>repo</distribution>
  79. <comments>A business-friendly OSS license</comments>
  80. </license>
  81. </licenses>
  82.  
  83. <!-- scm(software configuration management)标签允许你配置你的代码库,为Maven web站点和其它插件使用。
  84. 如果你正在使用CVS或Subversion,source repository页面同样能给如何使用代码库的详细的、工具相关的指令。 下面是一个典型SCM的配置例子 -->
  85. <scm>
  86. <!-- 项目在 svn 上对应的资源 -->
  87. <connection>
  88. scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)
  89. </connection>
  90. <developerConnection>
  91. scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk
  92. </developerConnection>
  93. <url>http://svn.baidu.com/banseon</url>
  94. </scm>
  95. <!-- 用于配置分发管理,配置相应的产品发布信息,主要用于发布,在执行mvn deploy后表示要发布的位置 -->
  96. <distributionManagement>
  97. <!-- 配置到文件系统 -->
  98. <repository>
  99. <id>banseon-maven2</id>
  100. <name>banseon maven2</name>
  101. <url>file://${basedir}/target/deploy</url>
  102. </repository>
  103. <!-- 使用ssh2配置 -->
  104. <snapshotRepository>
  105. <id>banseon-maven2</id>
  106. <name>Banseon-maven2 Snapshot Repository</name>
  107. <url>scp://svn.baidu.com/banseon:/usr/local/maven-snapshot</url>
  108. </snapshotRepository>
  109. <!-- 使用ssh2配置 -->
  110. <site>
  111. <id>banseon-site</id>
  112. <name>business api website</name>
  113. <url>
  114. scp://svn.baidu.com/banseon:/var/www/localhost/banseon-web
  115. </url>
  116. </site>
  117. </distributionManagement>
  118.  
  119. <!-- 依赖关系 -->
  120. <dependencies>
  121. <!--项目的模块依赖 -->
  122. <dependency>
  123. <groupId>junit</groupId>
  124. <artifactId>junit</artifactId>
  125. <version>3.8.1</version>
  126. <!-- scope 说明 -compile :默认范围,用于编译 -provided:类似于编译,但支持你期待jdk或者容器提供,类似于classpath
  127. -runtime: 在执行时,需要使用 -test: 用于test任务时使用 -system: 需要外在提供相应的元素。通过systemPath来取得
  128. -systemPath: 仅用于范围为system。提供相应的路径 -optional: 标注可选,当项目自身也是依赖时。用于连续依赖时使用 -->
  129. <scope>test</scope>
  130. <!-- <type>jar</type> <optional>true</optional> -->
  131. </dependency>
  132.  
  133. <!--外在告诉maven你只包括指定的项目,不包括相关的依赖。此因素主要用于解决版本冲突问题 如下依赖表示 项目acegi-security依赖
  134. org.springframework.XXX 项目,但我们不需要引用这些项目 -->
  135. <dependency>
  136. <groupId>org.acegisecurity</groupId>
  137. <artifactId>acegi-security</artifactId>
  138. <version>1.0.5</version>
  139. <scope>runtime</scope>
  140. <exclusions>
  141. <exclusion>
  142. <artifactId>spring-core</artifactId>
  143. <groupId>org.springframework</groupId>
  144. </exclusion>
  145. <exclusion>
  146. <artifactId>spring-support</artifactId>
  147. <groupId>org.springframework</groupId>
  148. </exclusion>
  149. <exclusion>
  150. <artifactId>commons-logging</artifactId>
  151. <groupId>commons-logging</groupId>
  152. </exclusion>
  153. <exclusion>
  154. <artifactId>spring-jdbc</artifactId>
  155. <groupId>org.springframework</groupId>
  156. </exclusion>
  157. <exclusion>
  158. <artifactId>spring-remoting</artifactId>
  159. <groupId>org.springframework</groupId>
  160. </exclusion>
  161. </exclusions>
  162. </dependency>
  163. <dependency>
  164. <groupId>org.springframework</groupId>
  165. <artifactId>spring</artifactId>
  166. <version>2.5.1</version>
  167. <scope>runtime</scope>
  168. </dependency>
  169. <dependency>
  170. <groupId>org.springframework</groupId>
  171. <artifactId>spring-web</artifactId>
  172. <version>2.5.1</version>
  173. <scope>runtime</scope>
  174. </dependency>
  175. <dependency>
  176. <groupId>postgresql</groupId>
  177. <artifactId>postgresql</artifactId>
  178. <version>8.2-504.jdbc4</version>
  179. <scope>runtime</scope>
  180. </dependency>
  181. <dependency>
  182. <groupId>com.oracle</groupId>
  183. <artifactId>ojdbc6</artifactId>
  184. <version>11.1.0.6</version>
  185. <scope>runtime</scope>
  186. </dependency>
  187. </dependencies>
  188.  
  189. <!--maven proxy, 本地仓库,替代 maven.apache.org 网站 jar 列表,用户下载时,首先寻找该站点 如资源找到,则下载。否则才去
  190. jar 列表网站。对多人团队,可节省下载速度和个人存储空间。 -->
  191. <repositories>
  192. <repository>
  193. <id>banseon-repository-proxy</id>
  194. <name>banseon-repository-proxy</name>
  195. <url>http://192.168.1.169:9999/repository/</url>
  196. <layout>default</layout>
  197. </repository>
  198. </repositories>
  199.  
  200. <!--插件库 -->
  201. <pluginRepositories>
  202. <pluginRepository>
  203. <id>banseon-repository-proxy</id>
  204. <name>banseon-repository-proxy</name>
  205. <url>http://192.168.1.169:9999/repository/</url>
  206. </pluginRepository>
  207. </pluginRepositories>
  208.  
  209. <!-- build配置 -->
  210. <build>
  211. <resources>
  212. <resource>
  213. <directory>src/main/resources</directory>
  214. <!-- 资源根目录排除各环境的配置,防止在生成目录中多余其它目录 -->
  215. <excludes>
  216. <exclude>prod/*</exclude>
  217. <exclude>dev/*</exclude>
  218. <exclude>test/*</exclude>
  219. </excludes>
  220. </resource>
  221. <resource>
  222. <directory>src/main/resources/${profiles.active}</directory>
  223. </resource>
  224. </resources>
  225. <plugins>
  226. <plugin>
  227. <artifactId>maven-war-plugin</artifactId>
  228. <version>2.2</version>
  229. <configuration>
  230. <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
  231. </configuration>
  232. </plugin>
  233. <plugin>
  234. <groupId>org.apache.maven.plugins</groupId>
  235. <artifactId>maven-compiler-plugin</artifactId>
  236. <version>3.1</version>
  237. <configuration>
  238. <encoding>utf8</encoding>
  239. <source>1.8</source>
  240. <target>1.8</target>
  241. </configuration>
  242. </plugin>
  243. <plugin>
  244. <artifactId>maven-jar-plugin</artifactId>
  245. <configuration>
  246. <includes>
  247. <include>**/com/**</include>
  248. </includes>
  249. <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/lib</outputDirectory>
  250. </configuration>
  251. <executions>
  252. <execution>
  253. <phase>prepare-package</phase>
  254. <goals>
  255. <goal>jar</goal>
  256. </goals>
  257. </execution>
  258. </executions>
  259. </plugin>
  260. <plugin>
  261. <groupId>org.apache.tomcat.maven</groupId>
  262. <artifactId>tomcat7-maven-plugin</artifactId>
  263. <version>2.2</version>
  264. <configuration>
  265. <port>8888</port>
  266. <path>/</path>
  267. <uriEncoding>UTF-8</uriEncoding>
  268. <server>tomcat7</server>
  269. </configuration>
  270. </plugin>
  271. </plugins>
  272. </build>
  273.  
  274. <!-- 资源目录配置,这里可以区分开发,测试,生产环境,只需要把相应的activeByDefault修改为true即可 -->
  275. <profiles>
  276. <profile>
  277. <id>dev</id>
  278. <properties>
  279. <profiles.active>dev</profiles.active>
  280. </properties>
  281. <activation>
  282. <activeByDefault>true</activeByDefault>
  283. </activation>
  284. </profile>
  285. <profile>
  286. <id>test</id>
  287. <properties>
  288. <profiles.active>test</profiles.active>
  289. </properties>
  290. <activation>
  291. <activeByDefault>false</activeByDefault>
  292. </activation>
  293. </profile>
  294. <profile>
  295. <id>prod</id>
  296. <properties>
  297. <profiles.active>prod</profiles.active>
  298. </properties>
  299. <activation>
  300. <activeByDefault>false</activeByDefault>
  301. </activation>
  302. </profile>
  303. </profiles>
  304. </project>

下面我贴一个常用的 POM 文件结构。

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>com.test.mall</groupId>
  5. <artifactId>wb_test_service</artifactId>
  6. <packaging>war</packaging>
  7. <version>0.0.1</version>
  8. <name>jd_market_service Maven Webapp</name>
  9. <url>http://maven.apache.org</url>
  10. <properties>
  11. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  12. <encoding>UTF-8</encoding>
  13. </properties>
  14. <dependencies>
  15. <dependency>
  16. <groupId>junit</groupId>
  17. <artifactId>junit</artifactId>
  18. <version>4.11</version>
  19. <scope>test</scope>
  20. </dependency>
  21. <dependency>
  22. <groupId>org.springframework</groupId>
  23. <artifactId>spring-webmvc</artifactId>
  24. <version>4.3.2.RELEASE</version>
  25. </dependency>
  26. <dependency>
  27. <groupId>log4j</groupId>
  28. <artifactId>log4j</artifactId>
  29. <version>1.2.16</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>org.apache.httpcomponents</groupId>
  33. <artifactId>httpcore</artifactId>
  34. <version>4.4.4</version>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.apache.httpcomponents</groupId>
  38. <artifactId>httpclient</artifactId>
  39. <version>4.5.2</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>commons-io</groupId>
  43. <artifactId>commons-io</artifactId>
  44. <version>2.4</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>com.google.code.gson</groupId>
  48. <artifactId>gson</artifactId>
  49. <version>2.2.4</version>
  50. </dependency>
  51. <dependency>
  52. <groupId>org.springframework</groupId>
  53. <artifactId>spring-test</artifactId>
  54. <version>4.2.4.RELEASE</version>
  55. </dependency>
  56. <dependency>
  57. <groupId>redis.clients</groupId>
  58. <artifactId>jedis</artifactId>
  59. <version>2.5.2</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.aspectj</groupId>
  63. <artifactId>aspectjweaver</artifactId>
  64. <version>1.8.9</version>
  65. </dependency>
  66.  
  67. <dependency>
  68. <groupId>cglib</groupId>
  69. <artifactId>cglib-nodep</artifactId>
  70. <version>2.1_3</version>
  71. </dependency>
  72. <dependency>
  73. <groupId>javax.inject</groupId>
  74. <artifactId>javax.inject</artifactId>
  75. <version>1</version>
  76. </dependency>
  77. </dependencies>
  78. <build>
  79. <resources>
  80. <resource>
  81. <directory>src/main/resources</directory>
  82. <!-- 资源根目录排除各环境的配置,防止在生成目录中多余其它目录 -->
  83. <excludes>
  84. <exclude>prod/*</exclude>
  85. <exclude>dev/*</exclude>
  86. <exclude>test/*</exclude>
  87. </excludes>
  88. </resource>
  89. <resource>
  90. <directory>src/main/resources/${profiles.active}</directory>
  91. </resource>
  92. </resources>
  93. <plugins>
  94. <plugin>
  95. <artifactId>maven-war-plugin</artifactId>
  96. <version>2.2</version>
  97. <configuration>
  98. <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
  99. </configuration>
  100. </plugin>
  101. <plugin>
  102. <groupId>org.apache.maven.plugins</groupId>
  103. <artifactId>maven-compiler-plugin</artifactId>
  104. <version>3.1</version>
  105. <configuration>
  106. <encoding>utf8</encoding>
  107. <source>1.8</source>
  108. <target>1.8</target>
  109. </configuration>
  110. </plugin>
  111. <plugin>
  112. <artifactId>maven-jar-plugin</artifactId>
  113. <configuration>
  114. <includes>
  115. <include>**/com/**</include>
  116. </includes>
  117. <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/lib</outputDirectory>
  118. </configuration>
  119. <executions>
  120. <execution>
  121. <phase>prepare-package</phase>
  122. <goals>
  123. <goal>jar</goal>
  124. </goals>
  125. </execution>
  126. </executions>
  127. </plugin>
  128. <plugin>
  129. <groupId>org.apache.tomcat.maven</groupId>
  130. <artifactId>tomcat7-maven-plugin</artifactId>
  131. <version>2.2</version>
  132. <configuration>
  133. <port>8888</port>
  134. <path>/</path>
  135. <uriEncoding>UTF-8</uriEncoding>
  136. <server>tomcat7</server>
  137. </configuration>
  138. </plugin>
  139. </plugins>
  140. </build>
  141.  
  142. <profiles>
  143. <profile>
  144. <id>dev</id>
  145. <properties>
  146. <profiles.active>dev</profiles.active>
  147. </properties>
  148. <activation>
  149. <activeByDefault>true</activeByDefault>
  150. </activation>
  151. </profile>
  152. <profile>
  153. <id>test</id>
  154. <properties>
  155. <profiles.active>test</profiles.active>
  156. </properties>
  157. <activation>
  158. <activeByDefault>false</activeByDefault>
  159. </activation>
  160. </profile>
  161. <profile>
  162. <id>prod</id>
  163. <properties>
  164. <profiles.active>prod</profiles.active>
  165. </properties>
  166. <activation>
  167. <activeByDefault>false</activeByDefault>
  168. </activation>
  169. </profile>
  170. </profiles>
  171. </project>

Maven 项目中的 pom.xml 文件内容说明的更多相关文章

  1. Maven项目中的pom.xml详解【转】

    什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者需要遵循的规则,缺陷管理系统,组织和licenses,项目的url, ...

  2. maven项目中的pom.xml

    需要配置的内容 1.配置头(自动生成) 2.maven项目的坐标(自动生成) <modelVersion>4.0.0</modelVersion> <groupId> ...

  3. 关于IDEA中maven项目中在pom.xml导入依赖报错的解决方法

    报错详情 今天使用springcloud中的hystrix做服务降级的时候,导入下面的依赖,出现红色波浪线的报错信息 <dependency> <groupId>org.spr ...

  4. Maven快速入门(四)Maven中的pom.xml文件详解

    上一章,我们讲了Maven的坐标和仓库的概念,介绍了Maven是怎么通过坐标找到依赖的jar包的.同时也介绍了Maven的中央仓库.本地仓库.私服等概念及其作用.这些东西都是Maven最基本.最核心的 ...

  5. springMVC+Mybatis的maven-web项目的pom.xml文件内容

    pom.xml文件内容 <!-- 第一行是XML头,指定了该xml文档的版本和编码方式 --> <project xmlns="http://maven.apache.or ...

  6. maven工程中防止mapper.xml文件被漏掉、未加载的方法

    maven工程中防止mapper.xml文件被漏掉.未加载的方法 就是在pom.xml文件中添加以下内容 <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉. --&g ...

  7. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):4、Maven项目转换与pom.xml配置

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

  8. IDEA中添加各种依赖pom.xml文件内容

    刚实习的小白,今天准备进入项目,纳尼,前辈把框架什么的都搭建好了,默默的抹了一把辛酸泪,刚刚接触自学框架的时候,添加依赖的时候总是各种问题,让前辈发给我之后,才发现人家写的代码相当优美了.下面就是前辈 ...

  9. POM(project Object Model) Maven包管理依赖 pom.xml文件

    什么是POM POM全称为“Project Object Model”,意思是工程对象模型.Maven工程使用pom.xml来指定工程配置信息,和其他文本信息.该配置文件以xml为格式,使用xml语法 ...

随机推荐

  1. tcp的发送端一个小包就能打破对端的delay_ack么?

    3.10内核,反向合入4.9的bbr. 最近分析bbr的时候,收集了线上的一些报文,其中有一个疑问一直在我脑海里面,如下: 本身处于delay_ack状态的客户端,大概40ms回复一个delay_ac ...

  2. Beta冲刺——第四天

    beat冲刺:第四天 各个成员今日完成的任务 成员 冯晓.马思远 彭辉.王爽 吴琼.郝延婷 今日完成任务 ·管理员功能模块的代码规范与测试 ·后台审稿系统代码规范 ·代码规范 ·系统审稿模块功能测试 ...

  3. FP数据库配置文件

  4. 大数据入门到精通12--spark dataframe 注册成hive 的临时表

    一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...

  5. ASP.NET Boilerplate-AbpSession

    /------2016-05-15/------介绍 如果一个应用支持登录,也许需要知道当前登录用户的一些操作,然而ASP.NET 本身对于展现层提供了Session的支持,ABP提供了 IAbpSe ...

  6. Flask最强攻略 - 跟DragonFire学Flask - 第九篇 Flask 中的蓝图(BluePrint)

    蓝图,听起来就是一个很宏伟的东西 在Flask中的蓝图 blueprint 也是非常宏伟的 它的作用就是将 功能 与 主服务 分开怎么理解呢? 比如说,你有一个客户管理系统,最开始的时候,只有一个查看 ...

  7. 100-days: twelve

    Title:   Mark Zuckerberg wants Facebook's to emulate China's WeChat, but can it? emulate v.效仿,模仿 As ...

  8. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

    Error starting ApplicationContext. To display the conditions report re-run your application with 'de ...

  9. 六、maven仓库中安装没有的jar包

    举例:安装dubbo.jar Dubbox 的 jar 包并没有部署到 Maven 的中央仓库中,大家在 Maven 的中央仓库中可以查找到 Dubbo 的最终版本是 2.5.3 , 阿里巴巴解散了 ...

  10. 每月最后一周的周六晚上21:00执行任务-crontab

    0 21 * * 6 /bin/sh /root/time.sh #“6”代表周六 时间判断脚本如下: #!/bin/bash if [ "$(date -d "+7 days&q ...