Spring 引导应用程序在 Vaadin 13(流程 1)兼容模式下运行,而不是在 Vaadin 14 下运行

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

自从本周二发布 Vaadin 14 以来,我已经尝试在我的 Spring-boot Web 应用程序中使用它。在我的 pom.xml 中包含依赖项工作正常。 运行 该应用程序也运行良好。但是,只要我通过浏览器连接到本地主机,就会收到以下消息:

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.
====================================================================

如错误中所述,显然 Vaadin 14 未 运行 正确设置,它正在设置回 Vaadin 13 兼容模式。 我现在想知道这是否与我的代码或依赖项的版本有关。我如何 check/find 找出应用程序重置为 Vaadin 13 兼容模式的原因?有没有办法 运行 应用程序在新的 Vaadin 14 上稳定? 下面包含我的 pom.xml 和我的代码,它只是发送点击消息的简单启动按钮。

我已经尝试通过更改应用程序属性来禁用 Vaadin 的调试模式。遗憾的是,这根本不起作用。

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>

代码:

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);
    }
}

默认情况下,在使用 Vaadin 10-13 创建的项目中,当将版本更新到 14.x.x 时,它将 运行 处于兼容模式,并且一切都应该像以前一样工作。您看到的警告不是错误,只是对正在使用哪种模式的解释,预计将 Vaadin 版本更改为 14.x.x

的现有项目

如果你想升级到基于 npm 的新模式用于 client-side 依赖管理和 JavaScript 模块用于依赖包含请查看 Vaadin 14 migration guide.

您应该将 vaadin-maven-pluginprepare-frontendbuild-frontend 目标添加到您的 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>