spring boot 启动失败,不报错,但是报这个No active profile set, falling back to default profiles: default

首先报No active profile set, falling back to default profiles: default是没有配置spring.profiles.active:

解决方案引入对应的文件,在application.yml中引入:

spring:
  profiles:
    active: dev

接下来在对应的目录中创建对应的不同环境的yml文件,如下图所示:
在这里插入图片描述
此时切换至开发环境,项目运行读取的是application-dev.yml配置,如果需要读取生产环境,将application.yml中的active:dev改成prod即可。如果需要添加更多环境配置。按此操作即可。

springboot启动失败不报错

显示情况如下所示


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.4)

2022-12-13 10:18:52.858  INFO 14232 --- [           main] c.k.s.SpringbootDemoApplication          : Starting SpringbootDemoApplication using Java 1.8.0_202 on 2F-KF03 with PID 14232 (D:\i-word\springboot-demo\target\classes started by Administrator in D:\i-word\springboot-demo)
2022-12-13 10:18:52.860  INFO 14232 --- [           main] c.k.s.SpringbootDemoApplication          : No active profile set, falling back to 1 default profile: "default"
2022-12-13 10:18:53.143  INFO 14232 --- [           main] c.k.s.SpringbootDemoApplication          : Started SpringbootDemoApplication in 0.496 seconds (JVM running for 0.992)

Process finished with exit code 0

这里是没有引入spring-boot-starter-web所导致,引入对应pom文件即可解决问题

 <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
当启动一个Spring Boot项目时,如果没有设置活动的配置文件,就会出现"No active profile set, falling back to default profiles: default"的提示。这是因为Spring Boot支持通过配置不同的profile来提供不同环境下的配置功能。例如,在开发、测试和生产环境中可能会使用不同的配置。通过激活相应的profile,可以指定使用对应环境的配置。 有几种方式可以指定profile: 1. 通过在启动时指定参数,如--spring.profiles.active=dev。 2. 通过在配置文件中指定,如在application.properties或application.yml文件中添加spring.profiles.active=dev。 3. 通过在IDE的配置中指定,如在Program arguments或VM options中添加-Dspring.profiles.active=dev。 4. 通过在操作系统的环境变量中指定,如在Enviroment variables中添加SPRING_PROFILES_ACTIVE=dev。 配置的优先顺序是,命令行参数的优先级最高,其次是配置文件中的设置,然后是IDE的配置,最后是操作系统的环境变量。如果没有指定任何profile,就会使用默认的default profile。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [spring boot profile配置和启动时no active profile set, falling back to default profiles: default的...](https://blog.csdn.net/benbenniaono1/article/details/105632264)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hello.Reader

请我喝杯咖啡吧😊

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值