The first configuration mode <build> <plugins> <plugin> <! GroupId >org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <layout>ZIP</layout> <includes> <include> <groupId>non-exists</groupId> <artifactId>non-exists</artifactId> </include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <excludes> <exclude>**/static/**</exclude> <exclude>**/templates/**</exclude> <exclude>**/*.properties</exclude> <exclude>**/*.xml</exclude> <exclude>**/*.yml</exclude> </excludes> </configuration> </plugin> <! Plugins </groupId> org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <! <outputDirectory>target/lib</outputDirectory> <excludeTransitive>false</excludeTransitive>
							<stripVersion>false</stripVersion>
							<includeScope>runtime</includeScope>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<copy todir="target/resources">
									<fileset dir="target/classes">
                                        <exclude name="com/**" />
										<exclude name="org/**" />
										<include name="**/static/**" />
										<include name="**/templates/**" />
										<include name="**/*.properties" />
										<include name="**/*.xml" />
										<include name="**/*.yml" />
									</fileset>
								</copy>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>

		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
				</includes>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.*</include>
				</includes>
			</resource>
		</resources>

	</build>

## Then run java-jar-dloader. path=resources,lib.jar
Copy the code
The second way<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<includes>
						<include>
							<groupId>null</groupId>
							<artifactId>null</artifactId>
						</include>
					</includes>
					<layout>JAR</layout>
					<addResources>true</addResources>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
						<configuration>
							<! *-run.jar -->
							<! Jar package special identifier not configured, original file named *.jar. Original, generate a new file *.jar -->
							<! --<classifier>run</classifier>-->
						</configuration>
					</execution>
				</executions>
			</plugin>

			<! - packaged jar - >
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<! -- Do not package resource files -->
					<excludes>
						<exclude>* * /static/**</exclude>
						<exclude>* * /templates/**</exclude>
						<exclude>/ * * *.properties</exclude>
						<exclude>/ * * *.xml</exclude>
						<exclude>/ * * *.yml</exclude>
					</excludes>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<! -- manifest.mf add prefix to class-path -->
							<classpathPrefix>. /lib/</classpathPrefix>
							<! -- Jar package does not contain unique version identifier -->
							<! --<useUniqueVersions>false</useUniqueVersions>-->
							<! -- Specify entry class -->
							<mainClass>com.huzhihui.otoctest.OtocTestApplication</mainClass>
						</manifest>
						<manifestEntries>
							<! -- manifest.mf add Class Path to resource file directory -->
							<Class-Path>. /resources/</Class-Path>
						</manifestEntries>
					</archive>
					<outputDirectory>The ${project.build.directory}</outputDirectory>
				</configuration>
			</plugin>

			<! Dependencies -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>The ${project.build.directory}/lib/
							</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<! Copy -- resources-->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<resources>
								<resource>
									<directory>src/main/resources</directory>
								</resource>
							</resources>
							<outputDirectory>The ${project.build.directory}/resources</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

Run java-jar xxx.jar
Copy the code