resources目录存放配置文件和资源文件:
static:静态文件的存放位置
application.properties:配置文件
我个人使用的是application.yml文件
创建application.yml:
创建完成
这两个配置文件可以同时存在的
application.properties执行权限大于application.yml,两种文件中配置语法也不同,具体 请查看:springboot 配置文件application.properties和application.yml-CSDN博客https://blog.csdn.net/weixin_41670405/article/details/136806282?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22136806282%22%2C%22source%22%3A%22weixin_41670405%22%7D 配置端口号:
默认端口为8080改成8099
server: port: 8099
修改静态资源位置:
一般情况下我们的静态资源都是放在静态目录下,有哪些静态资源目录呢?
resources/static
resources/public
在static目录下创建index.html页面:
访问地址:http://localhost:8099/index.html
在public目录下创建index.html页面:
访问地址:http://localhost:8099/index.html
可以发现访问地址是一致的,访问结果为:
两个静态资源目录中有相同的文件,那么static的文件权限高于public的文件权限
静态文件我不想放在静态目录下,如何设置呢?
spring: web: resources: static-locations: classpath:/
配置完成在resource下创建index.html文件
再次访问:location:8099/index.html
那要如何访问static和public下的index.html文件呢?
static访问路径:
http://localhost:8099/static/index.html
public访问路径:
http://localhost:8099/static/index.html