新建项目
搭建项目结构
导入依赖包
外层项目pom
内层模块pom
普通模块引包
启动模块打包
<?xml version="1.0"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.hikvision.idatafusion</groupId>
<artifactId>dgdpsiot</artifactId>
<version>${dgdpsiot.version}</version>
</parent>
<artifactId>dgdpsiot-starter</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hikvision.idatafusion</groupId>
<artifactId>dgdpsiot-business</artifactId>
<version>${dgdpsiot.version}</version>
</dependency>
<dependency>
<groupId>com.hikvision.idatafusion</groupId>
<artifactId>dgdpsiot-web</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hikvision.idatafusion</groupId>
<artifactId>dgdpsiot-api</artifactId>
<version>${dgdpsiot.version}</version>
</dependency>
</dependencies>
<build>
<finalName>dgdpsiot</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- 将资源文件打包放到指定目录,并设定编码格式为utf-8 -->
<!--可配置多个提取复制路径只需要 “<id>”名字不一样即可 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>
${project.build.directory}/_pkg/linux/bin/${project-name}/config
</outputDirectory>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
<nonFilteredFileExtension>zip</nonFilteredFileExtension>
<nonFilteredFileExtension>rar</nonFilteredFileExtension>
<nonFilteredFileExtension>doc</nonFilteredFileExtension>
<nonFilteredFileExtension>docx</nonFilteredFileExtension>
<nonFilteredFileExtension>exe</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<resources>
<resource>
<directory>src/main/</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}/</targetPath>
</resource>
<resource>
<directory>src/main/resources/</directory>
<excludes>
<exclude>version.txt</exclude>
<exclude>.gitinfo</exclude>
</excludes>
<filtering>true</filtering>
<targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}/config</targetPath>
</resource>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>version.txt</include>
</includes>
<filtering>true</filtering>
<targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}</targetPath>
</resource>
<resource>
<directory>src/main/bin/</directory>
<targetPath>${project.build.directory}/_pkg/linux/bin/${project-name}/bin/</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- 生成可执行JAR包命令 maven-jar-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${project.basedir}/target/classes</classesDirectory>
<!-- 这块建议将配置文件放到和jar同级,这样改配置文件方便,不用到jar里面修改,可以去掉这几行 -->
<excludes>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
<exlcude>.gitinfo</exlcude>
<exlcude>version.txt</exlcude>
</excludes>
<includes>
<include>**/com/**</include>
</includes>
<outputDirectory>
${project.build.directory}/_pkg/linux/bin/${project-name}
</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
<!-- 这个需要根据实际项目来 -->
<mainClass>com.hikvision.idatafusion.dgdpsiot.starter.DdgpsiotStarter</mainClass>
</manifest>
<manifestEntries>
<Class-Path>config/ lib/xmap-cluster-1.0.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- 拷贝依赖的jar包到lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/_pkg/linux/bin/${project-name}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--使用build-helper-maven-plugin插件来生成一个时间属性(默认的时间是GMT时间有时区差) -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>timestamp-property</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>build.time</name>
<pattern>yyyyMMddHHmmss</pattern>
<locale>zh_CN</locale>
<timeZone>GMT+8</timeZone>
</configuration>
</execution>
</executions>
</plugin>
<!--使用git-commit-id-plugin生成一个gitinfo,同时通过这个插件获取git.commit.id.abbrev属性 -->
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<id>get-the-git-infos</id>
<phase>initialize</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>false</verbose>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/.gitinfo
</generateGitPropertiesFilename>
<format>json</format>
<includeOnlyProperties>
<includeOnlyProperty>^git.branch$</includeOnlyProperty>
<includeOnlyProperty>^git.build.version$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.full$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.abbrev</includeOnlyProperty>
<includeOnlyProperty>^git.build.time$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.message.full$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<abbrevLength>11</abbrevLength>
</configuration>
</plugin>
</plugins>
</build>
</project>