For the most part, the web application just takes all the other modules and their Spring config
to load them in the webapp. The one exception is the implementation of
the ApplicationContextInitializer
that checks if anything has been set for the
Spring Profiles system property. If nothing is set, the HSQL DB profile is used as the
default Spring Profile. For production the PostgreSQL profile should be set.
Example 1. ContactApplicationContextInitializer
public class ContactApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final String SPRING_PROFILES_ACTIVE_PROPERTY = "spring.profiles.active"; private static final String PROFILE_HSQL = "hsql"; private final static String [] DEFAULT_ACTIVE_PROFILES = { PROFILE_HSQL }; @Override public void initialize(ConfigurableApplicationContext applicationContext) { String springProfilesActive = System.getProperty(SPRING_PROFILES_ACTIVE_PROPERTY); if (StringUtils.hasText(springProfilesActive)) { logger.info("Using set spring profiles. profiles='{}'", springProfilesActive); } else { applicationContext.getEnvironment().setActiveProfiles(DEFAULT_ACTIVE_PROFILES); logger.info("Setting default spring profiles. profiles='{}'", DEFAULT_ACTIVE_PROFILES); } } }