Creating Vaadin Flow Applications with Spring Boot using Gradle

In a lot of sites you can find information of Vaadin applications using Maven, the builds created with Maven can work perfect, but if you are a developer that prefer to use Gradle in the development process, this post will help you.

Tech Stack Used:

  • Platform for web development: Vaadin Flow.
  • Spring Framework: Spring Boot.
  • Build tool: Gradle.

We are going to start configuring the build.gradle with the Vaadin dependencies, vaadin-bom contains all dependencies to work with Vaadin Flow platform and vaadin-spring-boot-starter has the fundamental to use Spring Boot. This should looks like:

implementation(‘com.vaadin:vaadin-bom:12.0.6’) implementation(‘com.vaadin:vaadin-spring-boot-starter:12.0.6’)

Now, we need to package executable jar file with Gradle and the spring-boot-gradle-plugin helps us to achieve this just configuring the bootJar task with minor details:

bootJar {
baseName = 'hello-world-vaadin-springboot'
version = '0.0.1'
}

Remember include the URL repositories, you can add the oficial Vaadin repositories or you can use the maven central repository in the build.gradle:

maven {
url 'https://maven.vaadin.com/vaadin-prereleases'
}
maven {
url 'http://maven.vaadin.com/vaadin-addons'
}

That’s it!. We really apply few steps to configure a Gradle project to execute a Vaadin Flow application with Spring Boot.

In Github I have created a hello world demo, you can take a look at this link: https://github.com/dfcortes/hello-world-vaadin-springboot