package net.safedata.springboot.training.d01.s05;

import net.safedata.springboot.training.d01.s05.config.BeanProfilesConfig;
import net.safedata.springboot.training.d01.s05.config.Profiles;
import net.safedata.springboot.training.d01.s05.service.ProductService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * An example of how to use a Spring {@link org.springframework.core.env.Environment}
 */
public class EnvironmentUsageDemo {

    private static final String PROFILES_ACTIVATION_PROPERTY = "spring.profiles.active";

    public static void main(String[] args) {
        System.setProperty(PROFILES_ACTIVATION_PROPERTY, Profiles.PROD);

        final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(BeanProfilesConfig.class);

        final ProductService productService = applicationContext.getBean(ProductService.class);
        productService.displayProducts();
    }
}

@@ -256,16 +256,71 @@
 ervice;%0A
+import org.springframework.context.ApplicationContext;%0A
 import o
@@ -748,32 +748,16 @@
   final 
-AnnotationConfig
 Applicat

Use the ApplicationContext interface