此方式基于这个小伙伴的配置改的:https://blog.xlsea.cn/archives/710/
注意
spring-boot-maven-plugin
用不到的,仅做说明放这里systemScope
的 dependency
作参考maven-dependency-plugin
自动复制到 lib
目录maven-resources-plugin
自动复制到 config
目录-Dloader.path=lib,config
target/
目录下都可以看到)
config/**
:所有resources下的资源文件lib/**
:所有lib包,包括本地依赖xxx.jar
:应用Jarjava -jar xxx.jar
简略版配置
<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">
<properties>
<lib-path>liblib-path>
<config-path>configconfig-path>
<final-name>xxxfinal-name>
<main-class>org.jeecg.JeecgSystemApplicationmain-class>
properties>
<build>
<finalName>${final-name}finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<configuration>
<source>1.8source>
<target>1.8target>
<encoding>UTF-8encoding>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-surefire-pluginartifactId>
<configuration>
<skip>trueskip>
configuration>
plugin>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<configuration>
<skip>trueskip>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jar-pluginartifactId>
<configuration>
<archive>
<manifest>
<addClasspath>trueaddClasspath>
<classpathPrefix>${lib-path}/classpathPrefix>
<useUniqueVersions>falseuseUniqueVersions>
<mainClass>${main-class}mainClass>
manifest>
<manifestEntries>
<Class-Path>./${config-path}/ lib/zwdd-1.2.0.jar lib/spire-10.jarClass-Path>
manifestEntries>
archive>
<outputDirectory>${project.build.directory}outputDirectory>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<executions>
<execution>
<id>copy-dependenciesid>
<phase>packagephase>
<goals>
<goal>copy-dependenciesgoal>
goals>
<configuration>
<outputDirectory>${project.build.directory}/${lib-path}/outputDirectory>
configuration>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-resources-pluginartifactId>
<executions>
<execution>
<id>copy-resourcesid>
<phase>packagephase>
<goals>
<goal>copy-resourcesgoal>
goals>
<configuration>
<resources>
<resource>
<filtering>falsefiltering>
<directory>src/main/resourcesdirectory>
<includes>
<include>**/*include>
includes>
resource>
<resource>
<filtering>truefiltering>
<directory>src/main/resourcesdirectory>
<includes>
<include>*.ymlinclude>
includes>
resource>
resources>
<outputDirectory>${project.build.directory}/${config-path}outputDirectory>
configuration>
execution>
executions>
plugin>
plugins>
<resources>
<resource>
<directory>src/main/javadirectory>
<filtering>falsefiltering>
<includes>
<include>**/*.xmlinclude>
<include>**/*.jsoninclude>
<include>**/*.ftlinclude>
includes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>falsefiltering>
<excludes>
<exclude>**/*exclude>
excludes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>truefiltering>
<includes>
<include>*.ymlinclude>
includes>
resource>
resources>
build>
project>
完整配置(带部分注释)
<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">
<parent>
<groupId>org.jeecgframework.bootgroupId>
<artifactId>jeecg-boot-parentartifactId>
<version>2.4.0version>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>jeecg-boot-module-systemartifactId>
<repositories>
<repository>
<id>aliyunid>
<name>aliyun Repositoryname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
<snapshots>
<enabled>falseenabled>
snapshots>
repository>
repositories>
<dependencies>
<dependency>
<groupId>com.spiregroupId>
<artifactId>spireartifactId>
<version>10version>
<scope>systemscope>
<systemPath>${project.basedir}/../lib/Spire.Doc.jarsystemPath>
dependency>
<dependency>
<groupId>com.zwdd.apigroupId>
<artifactId>zwddartifactId>
<version>1.2.0version>
<scope>systemscope>
<systemPath>${project.basedir}/../lib/zwdd-sdk-java-1.2.0.jarsystemPath>
dependency>
dependencies>
<properties>
<lib-path>liblib-path>
<jar-path>jarjar-path>
<config-path>configconfig-path>
<final-name>xxxfinal-name>
<main-class>org.jeecg.JeecgSystemApplicationmain-class>
properties>
<build>
<finalName>${final-name}finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<configuration>
<source>1.8source>
<target>1.8target>
<encoding>UTF-8encoding>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-surefire-pluginartifactId>
<configuration>
<skip>trueskip>
configuration>
plugin>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<executions>
<execution>
<goals>
<goal>repackagegoal>
goals>
execution>
executions>
<configuration>
<skip>trueskip>
<mainClass>${main-class}mainClass>
<fork>truefork>
<addResources>trueaddResources>
<profiles>${profile.name}profiles>
<outputDirectory>${project.build.directory}/${jar-path}outputDirectory>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jar-pluginartifactId>
<configuration>
<excludes>
excludes>
<archive>
<manifest>
<addClasspath>trueaddClasspath>
<classpathPrefix>${lib-path}/classpathPrefix>
<useUniqueVersions>falseuseUniqueVersions>
<mainClass>${main-class}mainClass>
manifest>
<manifestEntries>
<Class-Path>./${config-path}/ lib/zwdd-1.2.0.jar lib/spire-10.jarClass-Path>
manifestEntries>
archive>
<outputDirectory>${project.build.directory}outputDirectory>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<executions>
<execution>
<id>copy-dependenciesid>
<phase>packagephase>
<goals>
<goal>copy-dependenciesgoal>
goals>
<configuration>
<outputDirectory>${project.build.directory}/${lib-path}/outputDirectory>
configuration>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-resources-pluginartifactId>
<executions>
<execution>
<id>copy-resourcesid>
<phase>packagephase>
<goals>
<goal>copy-resourcesgoal>
goals>
<configuration>
<resources>
<resource>
<filtering>falsefiltering>
<directory>src/main/resourcesdirectory>
<includes>
<include>**/*include>
includes>
resource>
<resource>
<filtering>truefiltering>
<directory>src/main/resourcesdirectory>
<includes>
<include>*.ymlinclude>
includes>
resource>
resources>
<outputDirectory>${project.build.directory}/${config-path}outputDirectory>
configuration>
execution>
executions>
plugin>
plugins>
<resources>
<resource>
<directory>src/main/javadirectory>
<filtering>falsefiltering>
<includes>
<include>**/*.xmlinclude>
<include>**/*.jsoninclude>
<include>**/*.ftlinclude>
includes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>falsefiltering>
<excludes>
<exclude>**/*exclude>
excludes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>truefiltering>
<includes>
<include>*.ymlinclude>
includes>
resource>
resources>
build>
project>
注意
org.springframework.boot.loader.PropertiesLauncher
maven-dependency-plugin
自动复制到 lib
目录maven-resources-plugin
自动复制到 config
目录-Dloader.path=lib路径,config路径
target/
目录下都可以看到)
config/**
:所有resources下的资源文件lib/**
:所有lib包,包括本地依赖xxx.jar
:应用Jarjava -Dloader.path=lib,config -Dspring.profiles.active=dev -jar main.jar
配置参考
<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">
<build>
<finalName>mainfinalName>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<configuration>
<source>1.8source>
<target>1.8target>
<encoding>UTF-8encoding>
<annotationProcessorPaths>
<path>
<groupId>org.mapstructgroupId>
<artifactId>mapstruct-processorartifactId>
<version>1.4.1.Finalversion>
path>
<path>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<version>1.18.12version>
path>
annotationProcessorPaths>
configuration>
plugin>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<configuration>
<mainClass>org.jeecg.JeecgSystemApplicationmainClass>
<includeSystemScope>falseincludeSystemScope>
<skip>falseskip>
<layout>ZIPlayout>
<includes>
<include>
<groupId>nothinggroupId>
<artifactId>nothingartifactId>
include>
includes>
configuration>
<executions>
<execution>
<goals>
<goal>repackagegoal>
goals>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<executions>
<execution>
<id>copy-dependenciesid>
<phase>packagephase>
<goals>
<goal>copy-dependenciesgoal>
goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/outputDirectory>
configuration>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-resources-pluginartifactId>
<executions>
<execution>
<id>copy-resourcesid>
<phase>packagephase>
<goals>
<goal>copy-resourcesgoal>
goals>
<configuration>
<resources>
<resource>
<filtering>falsefiltering>
<directory>src/main/resourcesdirectory>
<includes>
<include>**/*include>
includes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>truefiltering>
<includes>
<include>*.xmlinclude>
<include>*.ymlinclude>
<include>*.propertiesinclude>
includes>
resource>
resources>
<outputDirectory>${project.build.directory}/configoutputDirectory>
configuration>
execution>
executions>
plugin>
plugins>
<resources>
<resource>
<directory>src/main/javadirectory>
<filtering>falsefiltering>
<includes>
<include>**/*.xmlinclude>
<include>**/*.jsoninclude>
<include>**/*.ftlinclude>
includes>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<filtering>truefiltering>
<includes>
<include>*.ymlinclude>
<include>*.txtinclude>
includes>
resource>
resources>
build>
project>