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

标签 java spring vaadin vaadin-flow

自从本周二发布 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 兼容模式。 我现在想知道这是否与我的代码或依赖项的版本有关。如何检查/找出应用程序重置为 Vaadin 13 兼容模式的原因?有没有办法在新的 Vaadin 14 上稳定运行应用程序? 下面包含我的 pom.xml 和我的代码,它们只是发送点击消息的简单启动按钮。

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

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

最佳答案

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

关于java - Spring Boot 应用程序在 Vaadin 13(流程 1)兼容模式下运行,而不是在 Vaadin 14 下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56903081/

相关文章:

java - JSON - 简单获取 Integer 而不是 Long

java - 结合这两种方法

java - Spring Data JPA - 带模式匹配的不区分大小写的查询

Spring Data Rest - 添加到搜索端点的链接

java - Vaadin 8 网格分页

java - 获取 Activity UI 的 "Session Expired"消息

java - 为什么之前在 Itext7 中没有使用内容流将字体嵌入到 PDF 中?

java - Android 中的进度对话框不显示?

java - Vaadin:任务完成时无法获取进度对话框来接收/ react

java - 无法使用 JAXB org.springframework.oxm.UnmarshallingFailureException 解析 XML 消息