spring-boot 使用maven打包独立配置资源文件pom.xml 备忘

<build>
		<finalName>test</finalName>
		<!-- 留mapper.xml在jar包中 -->
		<resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <!-- 开启资源打包过滤 -->
                <filtering>true</filtering>
            </resource>
        </resources>
		<plugins>
			<!-- 打jar包 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>**/*.properties</exclude>
						<exclude>*.xml</exclude>
						<exclude>**/*.yml</exclude>
						<exclude>*.txt</exclude>
						<exclude>static/**</exclude>
					</excludes>
					<archive>
						<manifest>
							<!-- 指定Springboot程序启动类 -->
							<mainClass>com.wei.TestApplication</mainClass>
							<addClasspath>true</addClasspath>
							<!-- 指定依赖的jar包相对于本程序lib的位置 -->
							<classpathPrefix>lib/</classpathPrefix>
						</manifest>
						<manifestEntries>
							<!--MANIFEST.MF 中 Class-Path 加入资源文件目录 -->
							<Class-Path>./resources/${project.build.finalName}/</Class-Path>
						</manifestEntries>
					</archive>
				</configuration>
			</plugin>
			
			<!-- 该插件的作用是用于复制依赖的jar包到指定的文件夹里 -->
			<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>
							<type>jar</type>
							<includeTypes>jar</includeTypes>
							<useBaseVersion>false</useBaseVersion>
							<outputDirectory>
								${project.build.directory}/lib
							</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
			
			<!-- 拷贝资源文件 -->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/resources/${project.build.finalName}</outputDirectory>
							<resources>
								<resource>
									<directory>src/main/resources</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值