1 使用maven搭建父工程

妖狐艹你老母 2022-05-21 01:24 276阅读 0赞

完整项目搭建过程地址:
https://blog.csdn.net/mengmengdastyle/article/details/80820660

一、介绍

父工程应该是一个pom工程。
作用:在父工程中定义项目依赖的jar包的版本信息。

二、搭建过程

父项目名称platform-parent
1、使用maven进行创建
这里写图片描述
2、
这里写图片描述
3、父工程必须为pom
这里写图片描述
4、修改pom.xml文件
在父工程的pom文件中,定义jar包的版本。
后续子工程继承父工程时,就可以不需要在写版本号了!!!
注意:父工程中的jar包,在子工程中未必会全部用到。用哪些时再做引用,这个会在后面的项目中体现;
后续子工程需要添加新的jar包时,可以在父工程中增加。这里给出一部分主要的jar包及版本;

  1. <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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.platform</groupId>
  4. <artifactId>platform-parent</artifactId>
  5. <version>0.0.1-SNAPSHOT</version>
  6. <packaging>pom</packaging>
  7. <!-- 集中定义依赖版本号 -->
  8. <properties>
  9. <junit.version>4.12</junit.version>
  10. <spring.version>5.0.6.RELEASE</spring.version>
  11. <commons-lang3.version>3.7</commons-lang3.version>
  12. <commons-io.version>2.6</commons-io.version>
  13. <commons-net.version>3.6</commons-net.version>
  14. <commons-fileupload.version>1.3.1</commons-fileupload.version>
  15. <log4j2.version>2.10.0</log4j2.version>
  16. <slf4j.version>1.6.4</slf4j.version>
  17. <logback.version>1.2.3</logback.version>
  18. <mysql.version>5.1.46</mysql.version>
  19. <mongodb.version>3.6.3</mongodb.version>
  20. <mybatis.version>3.4.0</mybatis.version>
  21. <mybatis.spring.version>1.2.2</mybatis.spring.version>
  22. <mybatis.paginator.version>1.2.15</mybatis.paginator.version>
  23. <jackson.version>2.4.2</jackson.version>
  24. <druid.version>1.0.9</druid.version>
  25. <httpclient.version>4.3.5</httpclient.version>
  26. <jstl.version>1.2</jstl.version>
  27. <servlet-api.version>2.5</servlet-api.version>
  28. <jsp-api.version>2.0</jsp-api.version>
  29. <joda-time.version>2.5</joda-time.version>
  30. <pagehelper.version>3.4.2-fix</pagehelper.version>
  31. <jsqlparser.version>0.9.1</jsqlparser.version>
  32. <jedis.version>2.7.2</jedis.version>
  33. <solrj.version>4.10.3</solrj.version>
  34. </properties>
  35. <!-- 只定义依赖的版本,并不实际依赖 -->
  36. <dependencyManagement>
  37. <dependencies>
  38. <!-- 时间操作组件 -->
  39. <dependency>
  40. <groupId>joda-time</groupId>
  41. <artifactId>joda-time</artifactId>
  42. <version>${joda-time.version}</version>
  43. </dependency>
  44. <!-- Apache工具组件 -->
  45. <dependency>
  46. <groupId>org.apache.commons</groupId>
  47. <artifactId>commons-lang3</artifactId>
  48. <version>${commons-lang3.version}</version>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.apache.commons</groupId>
  52. <artifactId>commons-io</artifactId>
  53. <version>${commons-io.version}</version>
  54. </dependency>
  55. <dependency>
  56. <groupId>commons-net</groupId>
  57. <artifactId>commons-net</artifactId>
  58. <version>${commons-net.version}</version>
  59. </dependency>
  60. <!-- Jackson Json处理工具包 -->
  61. <dependency>
  62. <groupId>com.fasterxml.jackson.core</groupId>
  63. <artifactId>jackson-databind</artifactId>
  64. <version>${jackson.version}</version>
  65. </dependency>
  66. <!-- httpclient -->
  67. <dependency>
  68. <groupId>org.apache.httpcomponents</groupId>
  69. <artifactId>httpclient</artifactId>
  70. <version>${httpclient.version}</version>
  71. </dependency>
  72. <!-- 单元测试 -->
  73. <dependency>
  74. <groupId>junit</groupId>
  75. <artifactId>junit</artifactId>
  76. <version>${junit.version}</version>
  77. <scope>test</scope>
  78. </dependency>
  79. <!-- 日志处理 -->
  80. <dependency>
  81. <groupId>org.slf4j</groupId>
  82. <artifactId>slf4j-log4j12</artifactId>
  83. <version>${slf4j.version}</version>
  84. </dependency>
  85. <!-- Mybatis -->
  86. <dependency>
  87. <groupId>org.mybatis</groupId>
  88. <artifactId>mybatis</artifactId>
  89. <version>${mybatis.version}</version>
  90. </dependency>
  91. <dependency>
  92. <groupId>org.mybatis</groupId>
  93. <artifactId>mybatis-spring</artifactId>
  94. <version>${mybatis.spring.version}</version>
  95. </dependency>
  96. <dependency>
  97. <groupId>com.github.miemiedev</groupId>
  98. <artifactId>mybatis-paginator</artifactId>
  99. <version>${mybatis.paginator.version}</version>
  100. </dependency>
  101. <dependency>
  102. <groupId>com.github.pagehelper</groupId>
  103. <artifactId>pagehelper</artifactId>
  104. <version>${pagehelper.version}</version>
  105. </dependency>
  106. <!-- MySql -->
  107. <dependency>
  108. <groupId>mysql</groupId>
  109. <artifactId>mysql-connector-java</artifactId>
  110. <version>${mysql.version}</version>
  111. </dependency>
  112. <!-- 连接池 -->
  113. <dependency>
  114. <groupId>com.alibaba</groupId>
  115. <artifactId>druid</artifactId>
  116. <version>${druid.version}</version>
  117. </dependency>
  118. <!-- Spring -->
  119. <dependency>
  120. <groupId>org.springframework</groupId>
  121. <artifactId>spring-context</artifactId>
  122. <version>${spring.version}</version>
  123. </dependency>
  124. <dependency>
  125. <groupId>org.springframework</groupId>
  126. <artifactId>spring-beans</artifactId>
  127. <version>${spring.version}</version>
  128. </dependency>
  129. <dependency>
  130. <groupId>org.springframework</groupId>
  131. <artifactId>spring-webmvc</artifactId>
  132. <version>${spring.version}</version>
  133. </dependency>
  134. <dependency>
  135. <groupId>org.springframework</groupId>
  136. <artifactId>spring-jdbc</artifactId>
  137. <version>${spring.version}</version>
  138. </dependency>
  139. <dependency>
  140. <groupId>org.springframework</groupId>
  141. <artifactId>spring-aspects</artifactId>
  142. <version>${spring.version}</version>
  143. </dependency>
  144. <!-- JSP相关 -->
  145. <dependency>
  146. <groupId>jstl</groupId>
  147. <artifactId>jstl</artifactId>
  148. <version>${jstl.version}</version>
  149. </dependency>
  150. <dependency>
  151. <groupId>javax.servlet</groupId>
  152. <artifactId>servlet-api</artifactId>
  153. <version>${servlet-api.version}</version>
  154. <scope>provided</scope>
  155. </dependency>
  156. <dependency>
  157. <groupId>javax.servlet</groupId>
  158. <artifactId>jsp-api</artifactId>
  159. <version>${jsp-api.version}</version>
  160. <scope>provided</scope>
  161. </dependency>
  162. <!-- 文件上传组件 -->
  163. <dependency>
  164. <groupId>commons-fileupload</groupId>
  165. <artifactId>commons-fileupload</artifactId>
  166. <version>${commons-fileupload.version}</version>
  167. </dependency>
  168. <!-- Redis客户端 -->
  169. <dependency>
  170. <groupId>redis.clients</groupId>
  171. <artifactId>jedis</artifactId>
  172. <version>${jedis.version}</version>
  173. </dependency>
  174. <!-- solr客户端 -->
  175. <dependency>
  176. <groupId>org.apache.solr</groupId>
  177. <artifactId>solr-solrj</artifactId>
  178. <version>${solrj.version}</version>
  179. </dependency>
  180. </dependencies>
  181. </dependencyManagement>
  182. <build>
  183. <finalName>${project.artifactId}</finalName>
  184. <plugins>
  185. <!-- 资源文件拷贝插件 -->
  186. <plugin>
  187. <groupId>org.apache.maven.plugins</groupId>
  188. <artifactId>maven-resources-plugin</artifactId>
  189. <version>2.7</version>
  190. <configuration>
  191. <encoding>UTF-8</encoding>
  192. </configuration>
  193. </plugin>
  194. <!-- java编译插件 -->
  195. <plugin>
  196. <groupId>org.apache.maven.plugins</groupId>
  197. <artifactId>maven-compiler-plugin</artifactId>
  198. <version>3.2</version>
  199. <configuration>
  200. <source>1.7</source>
  201. <target>1.7</target>
  202. <encoding>UTF-8</encoding>
  203. </configuration>
  204. </plugin>
  205. </plugins>
  206. </build>
  207. </project>

发表评论

表情:
评论列表 (有 0 条评论,276人围观)

还没有评论,来说两句吧...

相关阅读