1.项目打包
<properties>
<classpathPrefix>libs</classpathPrefix>
<configPath>conf</configPath>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<!-- 配置要生成的jar -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- 配置jar包文件名称,自动生成后缀 -->
<finalName>${project.name}</finalName>
<archive>
<!-- 配置META-INF -->
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>${classpathPrefix}</classpathPrefix>
<mainClass>com.goisan.crawler.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>
${configPath}\ ${classpathPrefix}\ojdbc14_g-10.2.0.4.jar
</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>
${project.build.directory}\${project.name}
</outputDirectory>
</configuration>
</plugin>
<plugin>
<!-- 拷贝依赖jar -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}\${project.name}\${classpathPrefix}</outputDirectory>
<!-- 间接依赖也拷贝 -->
<excludeTransitive>false</excludeTransitive>
<!-- 带上版本号 -->
<stripVersion>false</stripVersion>
</configuration>
</execution>
</executions>
<configuration>
<!-- 发布本地引入的jar -->
<includeScope>system</includeScope>
</configuration>
</plugin>
</plugins>
<resources>
<!-- 配置文件外置 -->
<resource>
<directory>src\main\resources</directory>
<includes>
<include>*.properties</include>
</includes>
<filtering>false</filtering>
<targetPath>
${project.build.directory}\${project.name}\${configPath}
</targetPath>
</resource>
<!-- 配置文件外置 -->
<resource>
<directory>src\main\resources</directory>
<includes>
<include>*.bat</include>
</includes>
<filtering>false</filtering>
<targetPath>
${project.build.directory}\${project.name}
</targetPath>
</resource>
<!-- 配置文件内置 -->
<resource>
<directory>src\main\resources</directory>
<includes>
<include>*.xml</include>
<include>mapper\*.xml</include>
</includes>
</resource>
</resources>
</build>
2.引用本地jar包
<dependency>
<groupId>com.oracle</groupId>
<artifactId>oracle</artifactId>
<version>10.2.0.4</version>
<scope>system</scope>
<systemPath>${project.basedir}\src\main\libs\ojdbc14_g-10.2.0.4.jar</systemPath>
</dependency>
3.Spring boot 发布本地引入的jar
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
4.Spring boot 禁用插件
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
5.将指定jar编译到指定包下
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<!-- 要编译到jar中的依赖 groupId:artifactId -->
<include>ognl:ognl</include>
<include>com.h2database:h2</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<!-- 要修改位置的包名 -->
<pattern>ognl</pattern>
<shadedPattern>cn.org.rookie.demo.ognl</shadedPattern>
</relocation>
<relocation>
<pattern>org.h2</pattern>
<shadedPattern>cn.org.rookie.demo.h2</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
6.spring boot打包跳过测试
<properties>
<skipTests>true</skipTests>
</properties>
7.打包时加入文件
<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>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>${basedir}/../jeesdp-ui/dist</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
8.设置JDK版本
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
本文暂时没有评论,来添加一个吧(●'◡'●)