为什么我的com.vaadin.UI导入无法解决?

时间:2019-02-13 16:14:18

标签: java spring maven spring-boot vaadin

我正在尝试将com.vaddin.ui导入到我的Spring Boot Maven Java应用程序中,但无法解决我的导入问题。当我尝试使用MyView类扩展UI时,它一直在导入com.vaadin.flow.component.UIcom.vaadin.ui没有选项。

Import Can't be Resolved

这是我的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>

有人在我的依存关系中看到问题或知道可能是什么问题吗?

谢谢!

2 个答案:

答案 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