Skip to content

Support for Java 11 #1

@bartland

Description

@bartland

Thank you for this outstanding tutorial.

I am restricted to Java 11 for now. To do this I made simple updates to 2 files: pom.xml and HelloAppController.java.

pom.xml

Replace 17 with 11.

           <maven.compiler.release>11</maven.compiler.release>
           :
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                </configuration>
            </plugin>

HelloAppController.java

Replace private record Response (String message) {...}

with

    public class Response {
        String message;
        public Response(String message) {
            Objects.requireNonNull(message);
            this.message = message;
        }
        public boolean isValid() {
            return true;
        }
        public String getMessage() { return this.message; }

      @Override
      public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj == null || obj.getClass() != this.getClass()) return false;
        Response that = (Response) obj;
        return this.message == that.message;
      }

      @Override
      public int hashCode() {
        return Objects.hash(message);
      }

      @Override
      public String toString() {
        return this.message;
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions