Essential Vaadin 7 / Java EE Maven 3 POM 📎
With an additional Maven 3 dependency and three dependencies in total, you can integrate Vaadin 7 with your Java EE 6/7 backend in an efficient way. No XML configuration or any other configuration is needed.
With the cdi-integration you can not only inject EJBs and CDI managed beans directly to the UIs and views, but also expose the view with a single annotation:
import com.vaadin.cdi.CDIUI;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import javax.inject.Inject;
@CDIUI
public class WelcomePage extends UI {
@Inject
ReceptionService service;
@Override
protected void init(VaadinRequest request) {
setSizeFull();
String message = service.welcome();
Label label = new Label(message);
setContent(new HorizontalLayout(label));
}
}
@Stateless
public class ReceptionService {
public String welcome() {
return "Hello, Developer! No XML, No Configuration, and it works!";
}
}
The pom.xml
is based on a minimalistic Java EE template enhanced with three additional dependencies to Vaadin mentioned before:
<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>com.airhacks</groupId>
<artifactId>vaadin-with-javaee-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<url>http://airhacks.com</url>
<packaging>war</packaging>
<name>vaadin-with-javaee-pom</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-cdi</artifactId>
<version>1.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>7.0.4</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>7.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
A deployable Java EE project was pushed into https://github.com/AdamBien/vaadin-with-javaee-pom/
See you at Java EE Workshops at MUC Airport (particularly at JavaEE UI workshop)!