新建项目

image.png
image.png

搭建项目结构

image.png
image.png
image.png

导入依赖包

外层项目pom
image.png
内层模块pom
普通模块引包
image.png
启动模块打包

  1. <?xml version="1.0"?>
  2. <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>com.hikvision.idatafusion</groupId>
  7. <artifactId>dgdpsiot</artifactId>
  8. <version>${dgdpsiot.version}</version>
  9. </parent>
  10. <artifactId>dgdpsiot-starter</artifactId>
  11. <dependencies>
  12. <dependency>
  13. <groupId>junit</groupId>
  14. <artifactId>junit</artifactId>
  15. <version>3.8.1</version>
  16. <scope>test</scope>
  17. </dependency>
  18. <dependency>
  19. <groupId>com.hikvision.idatafusion</groupId>
  20. <artifactId>dgdpsiot-business</artifactId>
  21. <version>${dgdpsiot.version}</version>
  22. </dependency>
  23. <dependency>
  24. <groupId>com.hikvision.idatafusion</groupId>
  25. <artifactId>dgdpsiot-web</artifactId>
  26. <version>1.0.0-SNAPSHOT</version>
  27. </dependency>
  28. <dependency>
  29. <groupId>com.hikvision.idatafusion</groupId>
  30. <artifactId>dgdpsiot-api</artifactId>
  31. <version>${dgdpsiot.version}</version>
  32. </dependency>
  33. </dependencies>
  34. <build>
  35. <finalName>dgdpsiot</finalName>
  36. <plugins>
  37. <plugin>
  38. <groupId>org.apache.maven.plugins</groupId>
  39. <artifactId>maven-compiler-plugin</artifactId>
  40. <configuration>
  41. <source>${jdk.version}</source>
  42. <target>${jdk.version}</target>
  43. <encoding>${project.build.sourceEncoding}</encoding>
  44. </configuration>
  45. </plugin>
  46. <!-- 将资源文件打包放到指定目录,并设定编码格式为utf-8 -->
  47. <!--可配置多个提取复制路径只需要 “<id>”名字不一样即可 -->
  48. <plugin>
  49. <groupId>org.apache.maven.plugins</groupId>
  50. <artifactId>maven-resources-plugin</artifactId>
  51. <executions>
  52. <execution>
  53. <id>copy-resources</id>
  54. <phase>package</phase>
  55. <goals>
  56. <goal>copy-resources</goal>
  57. </goals>
  58. <configuration>
  59. <encoding>UTF-8</encoding>
  60. <outputDirectory>
  61. ${project.build.directory}/_pkg/linux/bin/${project-name}/config
  62. </outputDirectory>
  63. <nonFilteredFileExtensions>
  64. <nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
  65. <nonFilteredFileExtension>xls</nonFilteredFileExtension>
  66. <nonFilteredFileExtension>zip</nonFilteredFileExtension>
  67. <nonFilteredFileExtension>rar</nonFilteredFileExtension>
  68. <nonFilteredFileExtension>doc</nonFilteredFileExtension>
  69. <nonFilteredFileExtension>docx</nonFilteredFileExtension>
  70. <nonFilteredFileExtension>exe</nonFilteredFileExtension>
  71. </nonFilteredFileExtensions>
  72. <resources>
  73. <resource>
  74. <directory>src/main/</directory>
  75. <filtering>true</filtering>
  76. <targetPath>${project.build.directory}/</targetPath>
  77. </resource>
  78. <resource>
  79. <directory>src/main/resources/</directory>
  80. <excludes>
  81. <exclude>version.txt</exclude>
  82. <exclude>.gitinfo</exclude>
  83. </excludes>
  84. <filtering>true</filtering>
  85. <targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}/config</targetPath>
  86. </resource>
  87. <resource>
  88. <directory>src/main/resources/</directory>
  89. <includes>
  90. <include>version.txt</include>
  91. </includes>
  92. <filtering>true</filtering>
  93. <targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}</targetPath>
  94. </resource>
  95. <resource>
  96. <directory>src/main/bin/</directory>
  97. <targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}/bin/</targetPath>
  98. </resource>
  99. </resources>
  100. </configuration>
  101. </execution>
  102. </executions>
  103. </plugin>
  104. <!-- 生成可执行JAR包命令 maven-jar-plugin -->
  105. <plugin>
  106. <groupId>org.apache.maven.plugins</groupId>
  107. <artifactId>maven-jar-plugin</artifactId>
  108. <executions>
  109. <execution>
  110. <id>default-jar</id>
  111. <phase>package</phase>
  112. <goals>
  113. <goal>jar</goal>
  114. </goals>
  115. <configuration>
  116. <classesDirectory>${project.basedir}/target/classes</classesDirectory>
  117. <!-- 这块建议将配置文件放到和jar同级,这样改配置文件方便,不用到jar里面修改,可以去掉这几行 -->
  118. <excludes>
  119. <exclude>*.properties</exclude>
  120. <exclude>*.xml</exclude>
  121. <exlcude>.gitinfo</exlcude>
  122. <exlcude>version.txt</exlcude>
  123. </excludes>
  124. <includes>
  125. <include>**/com/**</include>
  126. </includes>
  127. <outputDirectory>
  128. ${project.build.directory}/_pkg/linux/bin/${project-name}
  129. </outputDirectory>
  130. </configuration>
  131. </execution>
  132. </executions>
  133. <configuration>
  134. <archive>
  135. <manifest>
  136. <addClasspath>true</addClasspath>
  137. <classpathPrefix>lib/</classpathPrefix>
  138. <useUniqueVersions>false</useUniqueVersions>
  139. <!-- 这个需要根据实际项目来 -->
  140. <mainClass>com.hikvision.idatafusion.dgdpsiot.starter.DdgpsiotStarter</mainClass>
  141. </manifest>
  142. <manifestEntries>
  143. <Class-Path>config/ lib/xmap-cluster-1.0.jar</Class-Path>
  144. </manifestEntries>
  145. </archive>
  146. </configuration>
  147. </plugin>
  148. <!-- 拷贝依赖的jar包到lib目录 -->
  149. <plugin>
  150. <groupId>org.apache.maven.plugins</groupId>
  151. <artifactId>maven-dependency-plugin</artifactId>
  152. <executions>
  153. <execution>
  154. <id>copy</id>
  155. <phase>package</phase>
  156. <goals>
  157. <goal>copy-dependencies</goal>
  158. </goals>
  159. <configuration>
  160. <outputDirectory>
  161. ${project.build.directory}/_pkg/linux/bin/${project-name}/lib
  162. </outputDirectory>
  163. </configuration>
  164. </execution>
  165. </executions>
  166. </plugin>
  167. <!--使用build-helper-maven-plugin插件来生成一个时间属性(默认的时间是GMT时间有时区差) -->
  168. <plugin>
  169. <groupId>org.codehaus.mojo</groupId>
  170. <artifactId>build-helper-maven-plugin</artifactId>
  171. <version>3.1.0</version>
  172. <executions>
  173. <execution>
  174. <id>timestamp-property</id>
  175. <goals>
  176. <goal>timestamp-property</goal>
  177. </goals>
  178. <configuration>
  179. <name>build.time</name>
  180. <pattern>yyyyMMddHHmmss</pattern>
  181. <locale>zh_CN</locale>
  182. <timeZone>GMT+8</timeZone>
  183. </configuration>
  184. </execution>
  185. </executions>
  186. </plugin>
  187. <!--使用git-commit-id-plugin生成一个gitinfo,同时通过这个插件获取git.commit.id.abbrev属性 -->
  188. <plugin>
  189. <groupId>pl.project13.maven</groupId>
  190. <artifactId>git-commit-id-plugin</artifactId>
  191. <executions>
  192. <execution>
  193. <id>get-the-git-infos</id>
  194. <phase>initialize</phase>
  195. <goals>
  196. <goal>revision</goal>
  197. </goals>
  198. </execution>
  199. </executions>
  200. <configuration>
  201. <verbose>false</verbose>
  202. <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
  203. <generateGitPropertiesFile>true</generateGitPropertiesFile>
  204. <generateGitPropertiesFilename>${project.build.outputDirectory}/.gitinfo
  205. </generateGitPropertiesFilename>
  206. <format>json</format>
  207. <includeOnlyProperties>
  208. <includeOnlyProperty>^git.branch$</includeOnlyProperty>
  209. <includeOnlyProperty>^git.build.version$</includeOnlyProperty>
  210. <includeOnlyProperty>^git.commit.id.full$</includeOnlyProperty>
  211. <includeOnlyProperty>^git.commit.id.abbrev</includeOnlyProperty>
  212. <includeOnlyProperty>^git.build.time$</includeOnlyProperty>
  213. <includeOnlyProperty>^git.commit.message.full$</includeOnlyProperty>
  214. </includeOnlyProperties>
  215. <commitIdGenerationMode>full</commitIdGenerationMode>
  216. <abbrevLength>11</abbrevLength>
  217. </configuration>
  218. </plugin>
  219. </plugins>
  220. </build>
  221. </project>