> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/25.-profiles/25.2.-programmatically-setting-profiles.md).

# 25.2.以编程方式设置profiles

在应用运行前，你可以通过调用`SpringApplication.setAdditionalProfiles(…)`方法，以编程的方式设置激活的配置，也可以使用Spring的`ConfigurableEnvironment`接口激活配置（profiles）。
