springboot打包jar,包括静态资源到jar中

最近项目开发,发现springBoot项目在使用maven打包时,我们静态资源文件都放在resource目录下面,大致如下:
在这里插入图片描述
在使用maven打包时,发现静态资源没有打进去。原来springBoot默认静态资源路径的时resources.

那解决静态资源文件使用maven打包问题的解决方案就有两种了:

1.将静态资源文件夹名从resource改为resources

在这里插入图片描述

2.在工程pom.xml中加入resource目录配置,手动去指定。我们习惯使用resource目录,所以使用了手动指定
<build>
	<finalName>shengshi-property-management</finalName>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
	<resources>
		<resource>
			<directory>src/main/resource</directory>
			<includes>
				<include>**/*</include>
			</includes>
		</resource>
	</resources>
</build>
3、使用eclipse打包springboot jar包

点击项目—>右键—> 选择 Run As

1、run as maven clean
2、run as maven install
or
直接使用 run as maven build 其中配置 clean install 或者 clean package 即可

转载:https://www.cnblogs.com/ANCAN-RAY/p/7723142.html

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值