我正在尝试将com.vaddin.ui
导入到我的Spring Boot Maven Java应用程序中,但无法解决我的导入问题。当我尝试使用MyView类扩展UI时,它一直在导入com.vaadin.flow.component.UI
。 com.vaadin.ui
没有选项。
这是我的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.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.thompson</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>BuildFirstBootStrap</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<vaadin.version>12.0.6</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
有人在我的依存关系中看到问题或知道可能是什么问题吗?
谢谢!
答案 0 :(得分:3)
自Vaadin 10以来,UI
类已移至该新程序包,但是您无需再扩展UI
。您必须在Vaadin组件上使用@Route
批注。例如:
@Route("")
public class UsersView extends VerticalLayout {
public UsersView() {
add(new Text("It works!"));
}
}
答案 1 :(得分:2)
[
"concert": {
"date": "2019-02-16 19:30:00",
"title": "Fancy title",
"location": "Fancy location"
},
"lineup": [
{
"name": "Band 1",
"perma": "band-1"
},
{
"name": "Band 234",
"perma": "band-234"
}
]
]
是com.vaadin.flow.component.UI
中Vaadin版本的正确导入。在以前的Vaadin版本中,导入为pom.xml
,但从未为com.vaadin.ui.UI
。