No active profile set, falling back to default profiles: default
前言
最近在IDEA中导入一个 springboot 项目,导入后发现配置文件不起作用,按照网上教程,检查pom.xml文件中是否存在
<packaging>pom</packaging>
(若存在,将其删除,再重新编译)
试了这个方法,好像不对路
后来又试图新建application.yml
spring:
profiles:
active: dev
发现还是不起作用
正文
在日志中看到一句
No active profile set, falling back to default profiles: default
查找后发现,是IDEA没有将resources文件夹正确识别出来
解决方法:
- 右键点击项目文件夹->Open Modules Settings
- 在界面左侧侧Project Settings->Modules中点击项目
- 在界面右侧文件树找到对应的resources文件夹,点击上方Mark as: Resources
- 点击确认,退出,重新编译,发现运行正常了(正常的yml配置文件中,配置的server端口号数字会变成蓝色)
参考
[1]. {解决 :No active profile set, falling back to default profiles: default 问题}(https://blog.csdn.net/weixin_42140801/article/details/127267102)