Dec 12, 2020

Spring Boot in Action Notes

What I tire of in new technologies, is when examples are made that are supposedly so simple, but then you go to run them and they fail. For example Spring Boot in Action, if you run this example on Windows using Java 1.8.x, it will fail. There is an error. I really wish documentation could live on its own without requiring access to Professor Snape's comments regarding how to actually perform the experiment. Spring in Action (page 28):

1. Java version
>gradle bootRun
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.

Which is weird, since on the gradle site, the instructions state that install should only be run on Java 1.8+. Spring boot also mentions 1.8 solution. https://docs.spring.io/spring-boot/docs/1.3.0.RELEASE/reference/htmlsingle/ Running any of the help options doesn't present solutions. If you look at the build.gradle it has only:

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

So modifying the build.gradle, including a new parameter for targetCompatibility, and setting both the sourceCompatibility and targetCompatibility to 1.8, then it worked.

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

Later I installed Java 11 for eclipse 2020-09 compatibility.

2. Java version

Later on, on page 35, it discusses running

mvn dependency:tree

But nowhere have we been instruction to install maven yet, and it fails.

3. Implicit maxlength

Chapter two example, the booklist has a hidden issue, there is apparently a maximum length on the description field, although there is no automatic validation to let the user know that. I tried entering the specs for Building Evolutionary Architectures: Support Constant Change and it will fail with a non-descript message, below.

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Dec 12 11:27:21 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).

It is not clear where this gradle-launched tomcat is storing its logs so at least I could look up the exception that occured. But trial and error made me convinced there is an arbitrary length limit on the description field. This string is only 506 characters, is there a 255 limit OOB? Anyhow, change the input to onl the first sentence, it works.

The software development ecosystem is constantly changing, providing a constant stream of new tools, frameworks, techniques, and paradigms. Over the past few years, incremental developments in core engineering practices for software development have created the foundations for rethinking how architecture changes over time, along with ways to protect important architectural characteristics as it evolves. This practical guide ties those parts together with a new way to think about architecture and time.
4. Remove Junit errors

If you upgrade sprint boot... such as I did to try to get a good version of spring that I could run in eclipse, I updated to spring-boot-2.4. I needed to add this the maven pom:

  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
  </dependency>
5. Remove deprecation warnings

Follow the instructions on baeldung.

6. Thymeleaf warnings

To remove thymeleaf html namespace warnings in the sample code, append Thymeleaf namespace attributes to the html tag:

  <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="http://www.thymeleaf.org"
    xmlns:sec="http://www.thymeleaf.org">
7. BR and HR element warnings
  <!doctype html>

No comments:

Post a Comment