Use Vaadin with CDI

The vaadin-cdi add-on allows you to use Vaadin with CDI. You need to package the add-on in your application, and need to deploy it to a Java EE 7 (or newer) compliant application server. For vaadin-platform user, what you need to do is adding the vaadin-bom dependency to the dependencyManagement section in your pom.xml:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
         <groupId>com.vaadin</groupId>
         <artifactId>vaadin-cdi</artifactId>
         <version>10.0.0</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

Compatibility

Version 10 of the add-on works with Vaadin version 10, and 11.

Minimum requirement is CDI 1.2 API, and a provided implementation. In practice other Java EE/Jakarta EE features are used together with CDI, so the most simple way is ensure you have a Java EE 7 container or newer.

Configuration

If you do not setup a Vaadin Servlet by web.xml, or by @WebServlet annotation, a CDI enabled Vaadin servlet com.vaadin.cdi.CdiVaadinServlet is deployed automatically.

Otherwise you can customize it just like the original Vaadin Servlet. No special CDI config options exist.

Please refer to Changing Flow behavior with runtime configuration for details about Vaadin Servlet configuration.