What is going wrong on the Spring Boot View Layer?

A Question from a student leads us to look at what happens in the Spring Boot view layer.

Today we are going to dive into a question from a student of mine. It may seem obvious to some people what is happening but unless you really understand what is going on in the Spring Boot View Layer It can be a little bit confusing.

Spring Boot View Layer

Good evening, Mr. Vega. How do you do? My name is Fabio and have a doubt about Spring Boot’s behavior.

So, I created an index.html file under the static folder (is index.html or any HTML file for that matter what you call a template? Is it just another way to refer to HTML files?) right after importing the project generated by the Initializer and ran the application, with the expected result (the application found and displayed the index). But when I moved on to creating a controller class, with the mapping of the root page, all of a sudden the application couldn’t find the HTML anymore, issuing an error message to the console to this effect:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", the template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]

When I move it to the templates folder, suddenly the application finds it. It’s as if when I try without a controller, Spring calls the shots, who looks for it under the static folder; and when I have a controller, it falls to Thymeleaf, who looks for it under templates. What’s going on?

Spring Boot 2.0 Roadmap

When will Spring Boot 2.0 be released and what can we expect from it?

I am a huge fan of open source projects but I love a well-maintained project even more. I like to know when milestones are scheduled to be released and what are some of the features we can expect in them. 

Spring Boot 2.0 Roadmap

The Spring Boot team does a very good job of making this information available to the public. Thanks to that we have a pretty good idea of when Spring Boot 2.0 is going to land and some of the features that it will include. In this article, I want to talk about that roadmap and share with you a pretty big announcement. 

What is JHipster & Why you need to start using it today!

A look at one of my favorite open source projects around.

In today’s post, I want to talk to you about one of my favorite open source projects around, JHipster. In short, JHipster is a Yeoman Generator used to create a Spring Boot and Angular project. When you get past building sample and demo projects there is a lot of different technologies and stacks that go into building a scalable, complete and modern web application. 

Greetings Java Hipsters

The goal of the project is to generate for you a complete and modern Web app, unifying:

  • A high-performance and robust Java stack on the server side with Spring Boot
  • A sleek, modern, mobile-first front-end with Angular and Bootstrap
  • A powerful workflow to build your application with Yeoman, Webpack/Gulp and Maven/Gradle

Spring Boot Command Line Runner

What is a Command Line Runner and how can I use it in my applications?

A student asked me the other day what a Command Line Runner was and when can we use one. If you watch demos of Spring Boot features or applications you have probably seen this and said to yourself “What the heck is that?”.

Command Line Runner

If you take a look a look at the API Documentation for Command Line Runner you will get this elegant explanation. 

Interface used to indicate that a bean should run when it is contained within a SpringApplication. Multiple CommandLineRunner beans can be defined within the same application context and can be ordered using the Ordered interface or @Order annotation.

In this article, I will explain what a Command Line Runner is and how we can take advantage of it in our applications. 

Using Project Lombok in your Spring Boot Project

How to cut down some of the boilerplate Java code in your next Spring Application

In this article, we get to take a look at an awesome little project called Project Lombok. If you have been following me for awhile now then you already know I am a huge fan of the Groovy Programming Language. It takes a lot of the things I don’t like in Java and makes them better. Like, way better! Groovy is also really GOOD at cutting down the amount of ceremonious code you have to write. 

If you are working on a Java project and are looking for a way to cut down some of the noise in your code I have a great solution for you. In this article, we are going to look at Project Lombok and dive into what it is and how to use it in your next Spring Boot Application. 

Spring Stereotype Annotations

What are Stereotype Annotations and how do I use them in the Spring Framework

When software developers get introduced to the Spring Framework there are some concepts that can be a little confusing. The good news is once we wrap our head around them they can become second nature. Spring has some specialized annotations called Stereotype Annotations. If that concept is new to you don’t worry, we are going to break everything down for you in this article. 

Stereotype & Annotation Defined

Before we dive into what Spring Stereotype annotations are I think it’s important for us to understand what these two words mean. The word stereotype is defined in the Merriam-Webster dictionary as:

stereotype: (noun) something conforming to a fixed or general pattern; especially : a standardized mental picture that is held in common by members of a group and that represents an oversimplified opinion, prejudiced attitude, or uncritical judgment

Spring Boot Convention Based Error Pages

Custom error pages for a given status code can now be created by following a convention based approach.

We have to remember that when we put applications out into the wild that things will go wrong. This can be in the form of a user going to a wrong URL or entering invalid data. As much as we like to always blame the users (it must be user error, right?) there are times when we as developers make mistakes.

What we need to understand is that it is ok for both the users and us to make mistakes as long as we account for them. When a user requests a URI that doesn’t exist we need to show them a proper 404 (page not found) error page. We can even take this one step further and provide additional resources on this page to help them find what they are looking for. In this article, we will look at some improvements in Spring Boot 1.4 that help us define convention based error pages.

In this article, we will look at some improvements in Spring Boot 1.4 that help us define convention based error pages.

Spring Boot Entity Scan

How to add entities outside of your main package to the component scan

I had a question from a student come up that a lot of new Spring developers come across. It has to do with creating components and in this case more specifically, entities. Let’s take a look at the question and then dive into the solution. 

Spring Boot Entity Scan

The Problem

Hey, I’m trying to get JPA to create the post and author tables and view them in the H2 console.  I copied every step in the video and tried the suggestions to change the JDBC url to :testdb.  I’ve also tried changing spring.datasource.name: to both test and testdb, all with no luck.  When the console comes up, there are no tables.  Any help would be most appreciated!!  Here is the code in a repo, if that helps!

Cloud-Native Java: O’Reilly Preview Edition

Cloud-Native Java: Designing Resilient Systems with Spring Boot, Spring Cloud, and Cloud Foundry

There is a free preview of a book on Cloud Native Java. I had a chance to go through the first chapter this evening and there is some really good information packed in there. Here is a little bit about the book and a link to download the preview.

We invite you to download the O’Reilly eBook: Cloud-Native Java: Designing Resilient Systems with Spring Boot, Spring Cloud, and Cloud Foundry, authored by Pivotal’s Josh Long and Kenny Bastani.

In four content-packed chapters, you will learn:

  • How to get started with Spring Initializr, the Spring Tool Suite, and the Spring Guides
  • The patterns, scalability, reliability, and agility of a cloud-native platform and cloud-native applications
  • About event-driven architectures with Spring Integration, and how Spring Cloud Stream makes it easy to define channels that are connected to messaging technologies
  • Why Spring Batch has become a widely used industry standard to support processing large volumes of records on the JVM

Spring Boot & AngularJS Functional Requirements Blab

A couple days ago I posted a sneak at what was coming. The proverbial cat has now been let out of the bag so I might as well share the news with you. For my 3rd course I have partnered up with my John Thompson  to bring you a course on how to build Spring Boot + AngularJS applications. This is the email John sent out so I thought it would just share that with you.

——–
Hola,

Designing an application is no easy task. And getting your end users to tell you what they want can be very difficult. After all, your customers are not always going to be other developers. Often, your customer does not write code. They’re probably not skilled in describing how an application should work. A lot of people can’t envision how an application should work.

The process of talking to your end customer about what an application should do is typically called a functional requirements interview. Exactly like it sounds, you’re going to interview your customer about what functionality they want your software to do.

Let’s say your application needs to log people into the system. This simple task brings up a lot of questions. Such as:

  • Who owns the login data? A local database, LDAP, Active Directory, OAuth?
  • Do you need social media logins?
  • Lost password emails?
  • Will you use “Remember me” cookies?
  • Will the system have different security roles?
  • If you’re storing passwords – what are the encryption requirements? minimum password requirements? How often do you require a change? How do you protect against a brute force password crack attempt?