Spring Boot with No Parent – Example

Normally, you need to use Spring Boot as parent. If you do not want to use its as parent, this page is for you.

This example is a part of  Spring Boot with all examples

Full Code with Spring Boot 1.5.9.RELEASE:

9_spring-boot-no-parent.zip

What you need for run this:

  • Maven 3
  • Java 8

What the code will do:

  • Show how to config Spring Boot as not parent
  • Also support JSP (most examples in internet do not have this)
  • Also support maven resource filter (again, most examples in internet do not care about this)

Explain:

This is the file structure:

Most of files are the same as Spring Boot with JSP and Spring Boot with Maven Resource Filter. If you want to see explanation, click in those links.

Only pom.xml is different, see the yellow lines here.

The keys are these lines:

  • Line 14

  otherwise you will get this error message when you do ‘mvn clean package’

  • Line 16-27

This is the main replacement as using Spring Boot as Parent.

  • Line 50

Since this is not Spring Boot as Parent,  you have to explicit define the version for spring-boot-maven-plugin.

  • List 46-51

Since this is not Spring Boot as Parent,  you have to explicit define where the resource folder is, more detail here:

  • Line 56-63

Since this is not Spring Boot as Parent,  you have to explicit define which goal to be hooked for spring-boot-maven-plugin. If you miss this, when you run this:

You will get this error message:

That is because spring-boot-maven-plugin does not manifest file to point to the main class (when ‘mvn clean package’), so the war file will not be executable file.

  • Line 65-75:

Since this is not Spring Boot as Parent,  you have to explicit define, what delimiter is. Normally maven uses “${}”, but in Spring Boot you should use “@”, more detail here:

Try:

run this in console:

Then run this to start:

You should see something like this:

Open a browser and try to go to this url:

Then you should see this:

And, go to this url:

You will get this:

Then stop the console by Ctrl + C (on Windows).

And start with this:

Open a browswer and try to go to this url:

You will get this: