spring-profiles
/spring-profiles
Configuration and profiles management in Spring Boot 3.x. Covers @Profile, @ConfigurationProperties, property sources, YAML/properties, external configuration, secrets management, and environment-specific beans. USE WHEN: user mentions "spring profiles", "@Profile", "@ConfigurationProperties", "environment configuration", "property sources", "profile groups", "conditional beans" DO NOT USE FOR: feature flags at runtime - consider feature flag libraries, Spring Cloud Config - use `spring-cloud-config` skill
- Author
- claude-dev-suite ↗
- Repository
- claude-dev-suite ↗
- Licence
- MIT
- Last repository change
- 21.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 3
No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Configuration and profiles management in Spring Boot 3.x. Covers @Profile, @ConfigurationProperties, property sources, YAML/properties, external configuration, secrets management, and environment-specific beans. USE WHEN: user mentions "spring profiles", "@Profile", "@ConfigurationProperties", "environment configuration", "property sources", "profile groups", "conditional beans" DO NOT USE FOR: feature flags at runtime - consider feature flag libraries, Spring Cloud Config - use `spring-cloud-config` skill
Triggers from the description
Original author description
Configuration and profiles management in Spring Boot 3.x. Covers @Profile, @ConfigurationProperties, property sources, YAML/properties, external configuration, secrets management, and environment-specific beans. USE WHEN: user mentions "spring profiles", "@Profile", "@ConfigurationProperties", "environment configuration", "property sources", "profile groups", "conditional beans" DO NOT USE FOR: feature flags at runtime - consider feature flag libraries, Spring Cloud Config - use `spring-cloud-config` skill
How it works
- Quick Start
- Profile Activation
- @ConfigurationProperties
- Conditional Beans
- Secrets Management
- Best Practices
- Production Checklist
- When NOT to Use This Skill
- Anti-Patterns
- Quick Troubleshooting
SKILL.md preview
---
name: spring-profiles
description: |
Configuration and profiles management in Spring Boot 3.x. Covers @Profile,
@ConfigurationProperties, property sources, YAML/properties, external
configuration, secrets management, and environment-specific beans.
USE WHEN: user mentions "spring profiles", "@Profile", "@ConfigurationProperties",
"environment configuration", "property sources", "profile groups", "conditional beans"
DO NOT USE FOR: feature flags at runtime - consider feature flag libraries,
Spring Cloud Config - use `spring-cloud-config` skill
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Spring Profiles & Configuration
## Quick Start
```java
@Configuration
@Profile("dev")
public class DevConfig {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.build();
}
}
@Configuration
@Profile("prod")
public class ProdConfig {
@Bean
public DataSource dataSource() {
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl(System.getenv("DATABASE_URL"));
return ds;
}
}
```
---
## Profile Activation
```yaml
# 1. application.yml
spring:
profiles:
active: dev
# 2. Environment variable: SPRING_PROFILES_ACTIVE=prod
# 3. Command line: java -jar app.jar --spring.profiles.active=prod
# 4. JVM property: java -Dspring.profiles.active=prod -jar app.jar
```
### Profile Groups
```yaml
spring:
profiles:
active: production
group:
production:
- prod
- prod-db
- prod-security
development:
- dev
- dev-db
- dev-tools
```
### Profile Expression
```java
@Profile("cloud & kubernetes") // AND
@Profile("dev | test") // OR
@Profile("!prod") // NOT
@Profile("(dev | test) & !integration") // Combined
```
---
## @ConfigurationProperties
```java
@ConfigurationProperties(prefix = "app")
@Validated
public class AppProperties {
@NotBlank
private String name;
@NotNull
private String version;
private final Security security = new Security();
@Validated
public static class Security {
@NotBlank
private String jwtSecret;
@Min(3600)
private long jwtExpiration = 86400;
@NotEmpty
private List<String> allowedOrigins = new ArrayList<>();
}
// Getters and setters
}
// Abilitazione
@Configuration
@EnableConfigurationProperties(AppProperties.class)
public class AppConfig {}
```
```yaml
app:
name: MyApplication
version: 1.0.0
security:
jwt-secret: ${JWT_SECRET}
jwt-expiration: 86400
allowed-origins:
- https://example.com
```
### Immutable Configuration (Record)
```java
@ConfigurationProperties(prefix = "app.mail")
public record MailProperties(
@NotBlank String host,
@Min(1) @Max(65535) int port,
String username,
@DefaultValue("false") boolean starttls
) {}
```
> **Full Reference**: See [properties.md](properties.md) for Property Sources, External Configuration (Config Server, K8s, Vault).
---
## Conditional Beans
```java
@Bean
@ConditionalOnProperty(name = "feature.email.enabled", havingValue = "true")
public EmailService emailService() {
return new RealEmailService();
}
@Bean
@Profile("dev")
public CacheManager devCacheManager() {
return new ConcurrentMapCacheManager();
}
@Bean
@ConditionalOnMissingBean(UserService.class)
public UserService defaultUserService() {
return new DefaultUserService();
}
```
> **Full Reference**: See [conditional.md](conditional.md) for Custom Conditions, Validation, Testing.
---
## Secrets Management
```yaml
spring:
datasource:
password: ${DB_PASSWORD}
app:
security:
jwt-secret: ${JWT_SECRET}
```
> **Full Reference**: See [secrets.md](secrets.md) for Jasypt Encryption, Vault Integration.
---
## Best Practices
| Do | Don't |
|----|-------|
| Use @ConfigurationProperties for structured config | Use @Value for complex config |
| Validate properties with Bean Validation | Skip validation |
| Use profile groups for complex environments | Duplicate configuration |
| Externalize all secrets | Commit secrets to repository |
| Use sensible default values | Require all properties |
---
## Production Checklist
- [ ] Secrets externalized (env vars, Vault)
- [ ] Profiles configured for each environment
- [ ] Validation enabled on all properties
- [ ] Default values for optional properties
- [ ] Profile groups for related config
- [ ] Configuration encrypted where needed
---
## When NOT to Use This Skill
- **Runtime feature flags** - Consider LaunchDarkly, Flipt
- **Centralized config** - Use `spring-cloud-config` skill
- **Secrets only** - Consider HashiCorp Vault directly
---
## Anti-Patterns
| Anti-Pattern | Problem | Solution |
|--------------|---------|----------|
| Secrets in git | Security vulnerability | Use env vars or secrets manager |
| Wrong prefix | Properties not loaded | Verify prefix matches YAML |
| Missing @Validated | Validation ignored | Add @Validated annotation |
| @Value for complex config | Unmaintainable | Use @ConfigurationProperties |
---
## Quick Troubleshooting
| Problem | Diagnostic | Fix |
|---------|------------|-----|
| Properties not loaded | Check prefix | Verify @ConfigurationProperties prefix |
| Profile not active | Check logs at startup | Set spring.profiles.active |
| Binding failed | Check type | Use correct types (Duration, etc.) |
| Env var not resolved | Check naming | Use UPPER_SNAKE_CASE |
---
## Reference Files
| File | Content |
|------|---------|
| [properties.md](properties.md) | Property Sources, External Configuration |
| [conditional.md](conditional.md) | Conditional Beans, Validation, Testing |
| [secrets.md](secrets.md) | Secrets Management, Encryption |
---
## External Documentation
- [Externalized Configuration](https://docs.spring.io/spring-boot/reference/features/external-config.html)
- [Profiles](https://docs.spring.io/spring-boot/reference/features/profiles.html)
Files in this package (4)
- SKILL.md 6 KB
- conditional.md 5 KB
- properties.md 6 KB
- secrets.md 3 KB
Versions
The database has no other skills named spring-profiles.
Database snapshot: 13.11.2026 · package version 5c9ce6927256 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95backend-spring-config
Use when reviewing Spring Boot configuration code — `@ConfigurationProperties`, `application.yml`/profiles, `@Bean` lifecycle, `@ConditionalOn*`, externalized config, secrets management. Triggers when `application*.yml`/`.properties` files or Spring `@Configuration` beans are in… - 100unit-test-config-properties
Provides patterns for unit testing `@ConfigurationProperties` classes with `@ConfigurationPropertiesTest`. Validates property binding, tests validation constraints, verifies default values, checks type conversions, and mocks property sources for Spring Boot configuration… - 100spring-testing-properties
Test Spring Boot configuration - @ConfigurationProperties binding and defaults, Bean Validation constraints on properties, and apps that must refuse to start on invalid config. Use when adding or changing configuration properties, their validation, or startup checks such as… - 100301-frameworks-spring-boot-core
Use when you need to review, improve, or build Spring Boot 4.0.x applications — including proper usage of @SpringBootApplication, component annotations (@Controller, @Service, @Repository), bean definition and scoping, configuration classes and @ConfigurationProperties (with… - 100spring-cloud-config
Spring Cloud Config for centralized configuration management in microservices. Covers Config Server, Config Client, Git backend, and dynamic refresh. USE WHEN: user mentions "spring cloud config", "config server", "centralized configuration", "@RefreshScope", "externalized… - 100configuration-properties
Use when introducing or correcting grouped Spring Boot configuration, typed property binding, validation, profiles or secret injection. Do not rewrite unrelated single-value configuration.