Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-2200

DO378-45: Ch4 S1: Config property in example does not match lecture (debugFlag vs debug-flag)

XMLWordPrintable

    • ILT, ROLE, VT
    • en-US (English)

      URL:
      Reporter RHNID:
      Section: -
      Language: en-US (English)||
      Workaround:

      Description: In the student guide, there is a config property file using the example prefix, explaining how ConfigProperties can be used instead of ConfigProperty:

      The above example could be refactored to use the @ConfigProperties annotation. First, you must add an example prefix to the names of your configuration values in application.properties, like the following:

      example.format=One format for %s unit.
      example.unit=meter
      example.debugFlag=true

      Then, in the below code sample, the class field is named the same, but the text underneath states that debug-flag would have been converted to debugFlag, causing confusion:

      public class ExampleConfiguration {
      private String format;
      private boolean debugFlag = false;
      private Optional<String> unit;
      ...output omitted...
      In this case, in the configuration, the debug-flag variable will have its hyphen translated into setting the following letter into an uppercase, mapping it to debugFlag.

      I have not tested, but it makes sense that debug-flag is mapped, because it is a valid property name, but not a valid Java field name.

      The book needs a fix in that area though.

              rht-zgutterman Zachary Gutterman
              gregab@p0f.net Grega Bremec
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: