1.以前静态资源是放在webapp中,然后打jar包,静态资源始终打不进jar包

eclipse中,Springboot项目打jar包时,静态资源没有打入jar包

2.后来把静态页面放在了resources下面的templates里面,css、img、js放在了resources下面的static下面

eclipse中,Springboot项目打jar包时,静态资源没有打入jar包

3.application.properties里面添加下面这句代码

spring.resources.static-locations=classpath:/templates/,classpath:/static/

eclipse中,Springboot项目打jar包时,静态资源没有打入jar包

4.访问:浏览器就可以直接访问了

eclipse中,Springboot项目打jar包时,静态资源没有打入jar包

5.打jar包:然后静态页面这些就打入进来了

eclipse中,Springboot项目打jar包时,静态资源没有打入jar包

 

相关文章:

  • 2021-04-29
  • 2021-04-25
  • 2021-12-15
  • 2021-05-18
  • 2021-09-12
  • 2021-12-19
  • 2022-01-09
猜你喜欢
  • 2021-04-13
  • 2021-10-29
  • 2021-12-12
  • 2022-12-23
  • 2021-03-26
  • 2021-08-01
  • 2021-09-10
相关资源
相似解决方案