Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Interview question

What are Spring Boot Profiles and how do you use them? स्प्रिंग बूट प्रोफाइल्स क्या हैं और इनका उपयोग कैसे करें?

Answer

Profiles let you define environment-specific beans and configuration, such as separate settings for dev, test, and production, and activate only one set at runtime.

Profile-specific properties live in files like application-dev.properties, and profile-specific beans are marked with @Profile("dev"). The active profile is set through the spring.profiles.active property, an environment variable, or a JVM argument, and Spring Boot merges the profile-specific file over the base application.properties.

@Service
@Profile("dev")
public class MockPaymentService implements PaymentService { }

// activate: --spring.profiles.active=dev

प्रोफाइल्स आपको एनवायरनमेंट-विशिष्ट बीन्स और कॉन्फिगरेशन डिफाइन करने देते हैं, जैसे dev, test और production के लिए अलग सेटिंग्स, और रनटाइम पर केवल एक सेट को सक्रिय करते हैं।

प्रोफाइल-विशिष्ट प्रॉपर्टीज़ application-dev.properties जैसी फाइलों में होती हैं, और प्रोफाइल-विशिष्ट बीन्स को @Profile("dev") से चिह्नित किया जाता है। सक्रिय प्रोफाइल spring.profiles.active प्रॉपर्टी, एनवायरनमेंट वेरिएबल, या JVM आर्ग्यूमेंट से सेट होता है।

@Service
@Profile("dev")
public class MockPaymentService implements PaymentService { }

// activate: --spring.profiles.active=dev

Was this answer clear?