简体   繁体   中英

Spring Boot application runs in Vaadin 13 (Flow 1) compatibilty mode and not in Vaadin 14

Since Vaadin 14 was released this Tuesday, I already tried using it in my Spring-boot web application. Including the dependencies in my pom.xml works fine. Running the application works fine as well. However, as soon as I connect to the localhost via my browser I get the following message:

2019-07-05 13:46:33.743  WARN 7812 --- [nio-8080-exec-1] c.v.f.s.DefaultDeploymentConfiguration   : 
====================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
====================================================================
2019-07-05 13:46:33.744  WARN 7812 --- [nio-8080-exec-1] c.v.f.s.DefaultDeploymentConfiguration   : 
====================================================================
Running in Vaadin 13 (Flow 1) compatibility mode.

This mode uses webjars/Bower for client side dependency management and HTML imports for dependency loading.

The default mode in Vaadin 14+ (Flow 2+) is based on npm for dependency management and JavaScript modules for dependency inclusion.

See http://vaadin.com/docs for more information.
====================================================================

As mentioned in the error, apparently Vaadin 14 is not running properly and it is setting back to the Vaadin 13 compatiblity mode. I am now wondering if this has something to do with my code or with the version of my dependencies. How can I check/find out why the application resets to Vaadin 13 compatibility mode? And is there a way to run the application stable on the new Vaadin 14? My pom.xml and my code, which is just the simple starter button that sends a click message are included below.

I have already tried disabling debug mode for Vaadin by changing the application properties. Sadly this did not work at all.

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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>vaadinneuneu</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>vaadinneuneu</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
        <vaadin.version>14.0.0.rc3</vaadin.version>
    </properties>

    <repositories>
        <!-- Repository needed for prerelease versions of Vaadin -->
        <repository>
            <id>vaadin-prereleases</id>
            <url>https://maven.vaadin.com/vaadin-prereleases</url>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <!-- Repository needed for prerelease versions of Vaadin -->
        <pluginRepository>
            <id>vaadin-prereleases</id>
            <url>https://maven.vaadin.com/vaadin-prereleases</url>
            <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>14.0.0.rc3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>



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

</project>

Code:

package com.example.vaadinneuneu;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;

@Route(value = "home")
@PWA(name = "Kram", shortName = "Base")

public class MainView extends VerticalLayout {

    public MainView() {
        Button button = new Button("Click Me!",
                event -> Notification.show("Clicked!"));

        add(button);
    }
}

You should add vaadin-maven-plugin with prepare-frontend and build-frontend goals to your pom.xml .

<plugin>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-maven-plugin</artifactId>
    <version>${vaadin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-frontend</goal>
                <goal>build-frontend</goal>
            </goals>
        </execution>
    </executions>
</plugin>

By default in project that was created with Vaadin 10-13 when updating the version to 14.xx it will run in compatibility mode and everything should work as before. The warning you see is not an error, just an explanation of which mode is being used and it's expected for existing project that have the Vaadin version changed to 14.xx

If you want to upgrade to the new mode based on npm for client-side dependency management and JavaScript modules for dependency inclusion take a look at the Vaadin 14 migration guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM