Spring Applications

Exercise: Hello Application (Configuration Classes)

  1. Profiles
    • Rename the existent command-line runner to SimpleRunner and add it to the profile dev
    • Implement another command-line runner InteractiveRunner that asks the user for his name and age, and add it to the profile prod
    • Run the application using the spring.profiles.active command line option
  2. External Properties
    • Write a configuration file application.properties that contains a property for the adult age
    • Inject the property value into the Hello service to decide which message to return
    • Use a command line option to override the property value
  3. Type-safe Properties
    • Implement a configuration class TimesOfDay with properties for the times of day
    • Add the spring-boot-starter-validation starter and use annotations to validate the properties
    • Inject an instance into the Greeting service to generate an appropriate daytime greeting