仅供参考:我发誓没有激活配置文件配置,例如 -D 或运行配置
\n\n当应用程序在没有任何激活配置文件的情况下启动时,dev
配置文件将默认激活。
我已经设置了spring.profile.default = dev
,并且我希望开发配置文件被激活。但事实并非如此。
Run Environment
Spring-Boot-版本:2.1.2 发布
\n\nWhat I\'m referred
1) 如何在 Spring Boot 应用程序中使用配置文件 - \n https://www.javacodegeeks.com/2019/07/profiles-spring-boot-application.html#respond
\n\n这是我所做的代码
\n\n/resources/application.properties
spring.profiles.default= dev\n\napplication.environment=This is a "Default" Environment\n
Run Code Online (Sandbox Code Playgroud)\n\n/resources/application-dev.properties
application.environment=This is a "dev" Environment\nserver.port= 8082\n
Run Code Online (Sandbox Code Playgroud)\n\n/ProfileController.java
@RestController\n@RequestMapping("/v1")\npublic class ProfileController {\n\n @Value("${application.environment}")\n private String applicationEnv;\n\n @GetMapping\n public String getApplicationEnv(){\n return applicationEnv;\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\nlocalhost/v1 …