Errata

Chapter 1

Section 1.5.2 on page 22.

The archetype used to create the first application is not the one listed in the book. The name of the artifact is maven-archetype-webapp and has the coordinates:

Table 1.8 Coordinates for the maven webapp archetype
Group IDorg.bytesizebook.com.guide.boot
Artifact IDmaven-archetype-webapp
Version1.0

Section 1.5.3 on page 24.

The coordinates for the maven-archetype-webap have changed. The original command was

$ mvn archetype:generate
    -DgroupId=org.bytesizebook.com.guide.boot\
    -DartificatId=basic-webapp\
    -DpackageName=com.bytesizebook.com\
    -DarchetypeArtifactId=maven-archetype-webapp
                

The original command is missing properties for the archetype. The first three properties in the original command can have any values. Two additional properties for the archetype must be included.

$ mvn archetype:generate
    -DgroupId=org.bytesizebook.com.guide.boot\
    -DartificatId=basic-webapp\
    -DpackageName=com.bytesizebook.com\
    -DarchetypeArtifactId=maven-archetype-webapp\
    -DarchetypeGroupId=org.bytesizebook.com.guide.boot\
    -DarchetypeVersion=1.0
                

The archetype contains the starting code for the examples in the first three chapters of the book.

Chapter 4

Section 4.2.2 on page 133

The command to declare a command line argument is incorrect. It is missing a hyphen. The part of the command that starts with -program should begin with --program.

mvn spring-boot:run -Dspring-boot.run.arguments=--program=automobile

Section 4.232 on page 134

The command to declare a command line argument is incorrect. It is missing a hyphen. The part of the command that starts with -program should begin with --program.

mvn spring-boot:run -Dspring-boot.run.arguments=--program=none

Section 4.2 on page 129

The starter code for this chapter has been moved to the central repository. The new coordinates are different that the ones listed in the book. Always take the latest version of the code. The current version is 1.0.1. The only difference from the book's coordinates is the version:

  • Group ID: com.bytesizebook
  • Artifact ID: spring-boot-java-cli
  • Version: 1.0.1

Use the coordinates of this archetype to generate the starting code, as in Chapter 1. This is one command that appears on one line. The \ character is used to escape the newline character so it can be displayed in the book.

mvn archetype:generate \
    -DgroupId=com.bytesizebook \
    -DartifactId=spring-cli \
    -DpackageName=com.bytesizebook \
    -DarchetypeGroupId=com.bytesizebook \
    -DarchetypeArtifactId=spring-boot-java-cli \
    -DarchetypeVersion=1.0.1
    

The exact values for the archetype can be seen by searching for com.bytesizebook in search.maven.org.

If the archetype is not selected automatically and you are asked to enter a filter, enter spring-boot-java-cli and select the one for bytesizebook.

Section 4.2.2 on page 133

Once the archetype is generated, run it with the following command. Unfortunately, the typesetter for the book changed -- to - in the text. The correct command is here:

mvn spring-boot:run -Dspring-boot.run.arguments=--program=automobile
    

These commands use a different value for the program variable.

mvn spring-boot:run -Dspring-boot.run.arguments=--program=client

mvn spring-boot:run -Dspring-boot.run.arguments=--program=none

Chapter 5

Section 5.4.2 on page 190

The uri for the taglib should use http, not https

<%@ taglib prefix="form"
              uri="http://www.springframework.org/tags/form" %>

Section 5.6.2 on page 201

The PostMapping is using the query string instead of the path information. Modify the annotation to

    @PostMapping("confirm")

The method is using both session and model attributes as an example to explain the implications of using both of them. The technique used earlier in the chapter with only the ModelAttribute parameter is the simplest way to retrieve the data from the request and populate the bean.

    @PostMapping("confirm")
    public String confirmMethod(
            @ModelAttribute("data") Optional dataForm) {
        if (! dataForm.isPresent()) return "redirect:expired";
        return "redirect:confirm";
    }

Section 5.6.3 on page 203

The name in the qualifier annotation should be protoDefaultBean.

Section 5.7.3 on page 212.

Section 5.7.3 includes the FATAL level for loggers. Many logging packages have a FATAL level, but Slf4j does not. When using Slf4j, avoid using the FATAL level. The possible messages for Slf4j are:

logger.trace("message");
logger.debug("message");
logger.info("message");
logger.warn("message");
logger.error("message");

Chapter 6

Section 6.2.1 on page 241

The confirm and process pages have slight modifications from the versions in Chapter 5. They both have to include the new field for the days per week.

Confirm View

After displaying the information for the hobby and aversion, display the information for the days per week.

      <br>
      The value of the days per week that was sent to 
      this page is: <strong>${data.daysPerWeek}</strong>
Process View

Include the information for the days per week along with the information for the hobby and aversion.

      <p>
      Thank you for your information. Your hobby of 
      <strong>${data.hobby}</strong>, aversion of 
      <strong>${data.aversion}</strong> and days per week of 
      <strong>${data.daysPerWeek}</strong> will be added to our 
      records, eventually.

Section 6.3.2 on page 248

The interface named RequestDataWithDays is not needed. It is not used in the rest of the section. It would be needed if addValidator was used in the initBinder method in the controller.

Section 6.3.2 on page 250

  1. The error message for a small number in the validateDays method should read "must be greater than 0, if this is a hobby".
  2. The last controller used the session attributes to define the bean. The example in the book for this section is using a session scoped bean, instead. Both methods work, but the session attribute should be used to agree with the most recent controller.
        @Autowired
        @Qualifier("protoRequiredBean")
        private ObjectFactory requestDataProvider;
        
        @ModelAttribute("data")
        public RequestDataRequired getData() {
            logger.trace("called getData");
            return requestDataProvider.getObject();
        }

Section 6.3.2 on page 252

The error message for a small number in the RequestDataRequiredGroup interface should read "must be greater than 0, if this is a hobby".

Section 6.3.2 on page 253

In addition to the modification to the confirm method, the controller must:

  1. Set its URL pattern
  2. Reference the new interface for the object factory and data accessor
  3. Modify the initBinder method and change setValidator to addValidators, passing the new validator.

In the bean for the application, change all occurrences of the NotNulll annotation to NotEmpty, so an empty string is detected.

Section 6.4.2 page 259

The Transient annotation for the isValidHobby method is missing the @ sign.

    @Transient
    public boolean isValidHobby() {
        return hobby != null && !hobby.trim().equals("")
            && !hobby.trim.toLowerCase().equals("time travel");
    }

Section 6.4.3 page 275

The HREF for the View All Records buttons should be ../view.

Section 6.5 page 276

The steps for the application also require creating an interface for the persistent bean. Extend the interface from the required validation interface and add a public property for the id. Do not add a setter for the id.

Chapter 7

Section 7.7.1 page 320

Ignore the first paragraph in the section. The controller will still handle post requests as in the previous examples.


Contact the author