RAD–1: Spring for Vaadin 7.4.0

My whole effort to create rapid application development (RAD) stack for Java Web Development. I chose Vaadin for front end development. My development environment is Intellij Idea 14. In this example, I am going to use the recently released Vaadin Spring Add on.

As a first, create a spring boot web application. You have to select the “war” option for the packaging and select the option “web” for the dependencies.

        <dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot</artifactId>
<version>1.0.0.alpha2</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>7.4.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>7.4.0</version>
</dependency>

It is important to add the above dependencies to the newly created project.  Let us create just a simple view

package au.com.blogspot.ojitha.vaadin.view;

import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;

/**
* Created by Ojitha on 8/03/2015.
*/
@Theme("valo")
@SpringUI("")
public class RootUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {
getPage().setTitle("Root UI");
setContent(new Label("Hello ojtha, World!"));
}
}

Application is ready to deploy to tomcat 8. You can configure the tomcat in the File->Settings->Build, Execution, Deployment->Application Server. After that you can create a new “Run Configuration…” and create tomcat local configuration and add the web application (war or exploded) to that. Good to note that, under the Deployment tab, Application context should be specify. 

Here the complete pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>au.com.blogspot.ojitha</groupId>
<artifactId>vaadinex1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>vaadin-example-1</name>
<description>Vaadin spring example</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>au.com.blogspot.ojitha.vaadin.VaadinExample1Application</start-class>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency-->
<!--dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency-->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot</artifactId>
<version>1.0.0.alpha2</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>7.4.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>7.4.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<!--plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot</artifactId>
</plugin-->
</plugins>
</build>

</project>

Comments are welcome.

Comments

Popular posts from this blog

How To: GitHub projects in Spring Tool Suite

Spring 3 Part 7: Spring with Databases

Parse the namespace based XML using Python