自从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的调试模式。遗憾的是,这根本不起作用。
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);
}
}
答案 0 :(得分:0)
您是否有理由进入npm(非v13兼容模式)?该消息只是警告,不是错误。 npm模式仍然有点漏洞,实际上是Vaadin 14发行版仍未解决的根本原因。因此,此时保持在兼容模式下运行就可以了。同样,如果升级,则所有可能的模板文件都需要手动更改为Polymer 3格式。
要通过Spring Boot应用程序真正进入npm基本工作流程,您需要在application.properties文件中添加以下行:
vaadin.compatibilityMode
答案 1 :(得分:0)
在使用Vaadin 10-13创建的项目中,默认情况下,将版本更新为14.x.x时,它将以兼容模式运行,并且所有内容都应像以前一样工作。您看到的警告不是错误,只是对使用哪种模式的解释,对于Vaadin版本已更改为14.x.x
的现有项目,这应该是预期的如果您要升级到基于npm的新模式以进行客户端依赖管理,请使用JavaScript模块来包含依赖,请查看Vaadin 14 migration guide。
答案 2 :(得分:0)
您应将vaadin-maven-plugin
和prepare-frontend
个目标的build-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>