springboot(五)- 日志支持、访问静态资源

一、日志支持

spring boot 默认支持 slf4j

1、获取日志对象

@SpringBootTest
class MyspringbootApplicationTests {
	
	private final static Logger loger=LoggerFactory.getLogger(MyspringbootApplicationTests.class);
	
}

2、日志级别

TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF

spring boot 默认日志级别为 info

3、修改日志级别

logging.level.主配置类所在的包名 = 日志级别

logging.level.com.slq.myspringboot=info

二 、访问静态资源

1、访问第三方资源

进入 webjars 引用 jquery 的依赖包

<dependency>
	<groupId>org.webjars</groupId>
	<artifactId>jquery</artifactId>
	<version>3.6.0</version>
</dependency>

引入依赖后:
在这里插入图片描述

访问 jquery.js 文件

http://localhost:8001/webjars/jquery/3.6.0/jquery.js

2、访问自定义静态资源文件

自定义资源文件存放位置:

  • classpath:/META-INF/resources/
  • classpath:/resources/
  • classpath:/static/
  • classpath:/public/

优先级由高到低
在这里插入图片描述

访问静态资源,直接访问,不用添加文件路径

http://localhost:8001/aa.png

当静态资源文件夹中存在 index.xx 文件时 ,spring boot 默认其为首页页面
只需通过访问 http://localhost:8001 则直接进入该 index.xx 页面

3、设置网页图标

在任意静态资源目录中存放一个名为 favicon.ico 的图像即可

4、自定义静态资源存放位置

将静态资源存放位置改为类路径下的: myres 、myimg

spring.resources.static-locations=classpath:/myres/,classpath:/myimg/

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值