首先报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>