我是 Vaadin 初学者。我尝试实现教程中的代码,但我的应用程序无法编译。这是一个简单的 Spring Boot 应用程序,由三个类组成。第一个类是spring boot的入口点,主类。其他两个类是 vaadin 类。
<?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>
<groupId>com.demo</groupId>
<artifactId>vaadin-tut</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>vaadin-tut</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vaadin.version>8.2.0</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</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>
TodoUI 类
@SpringUI
public class TodoUI extends UI {
private VerticalLayout root;
@Autowired
private TodoLayout todoLayout;
@Override
protected void init(VaadinRequest vaadinRequest) {
setLayout();
addHeader();
addForm();
addTodoList();
addDeleteButton();
}
private void setLayout() {
root = new VerticalLayout();
setContent(root);
}
private void addHeader() {
root.addComponent(new Label("TODOs"));
}
private void addForm() {
HorizontalLayout formLayout = new HorizontalLayout();
TextField task = new TextField();
Button add = new Button("Add");
formLayout.addComponents(task, add);
root.addComponent(formLayout);
}
private void addTodoList() {
root.addComponent(todoLayout);
}
private void addDeleteButton() {
root.addComponent(new Button("Deleted Completed"));
}
}
ToDo 布局类
@SpringComponent
public class TodoLayout extends VerticalLayout {
}
这是服务器日志
Information:java: /root/.m2/repository/com/vaadin/vaadin-server/8.2.0/vaadin-server-8.2.0.jar(/com/vaadin/server/AbstractClientConnector.java) uses unchecked or unsafe operations.
Information:java: Recompile with -Xlint:unchecked for details.
Information:java: Errors occurred while compiling module 'vaadin-tut'
Information:javac 9.0.1 was used to compile java sources
Information:1/16/18 12:16 AM - Compilation completed with 2 errors and 6 warnings in 3s 1ms
Error:java: method <T>addAction(T) is already defined in interface com.vaadin.event.Action.Notifier
Error:java: method <T>removeAction(T) is already defined in interface com.vaadin.event.Action.Notifier
Warning:java: com.vaadin.ui.LegacyComponent in com.vaadin.ui has been deprecated
Warning:java: com.vaadin.server.LegacyCommunicationManager in com.vaadin.server has been deprecated
Warning:java: encodeState(com.vaadin.server.ClientConnector,com.vaadin.shared.communication.SharedState) in com.vaadin.server.LegacyCommunicationManager has been deprecated
Warning:java: createConnectorId(com.vaadin.server.ClientConnector) in com.vaadin.server.VaadinSession has been deprecated
Warning:java: removeListener(java.lang.Class<?>,java.lang.Object,java.lang.String) in com.vaadin.event.MethodEventSource has been deprecated
Warning:java: removeListener(java.lang.Class<?>,java.lang.Object,java.lang.reflect.Method) in com.vaadin.event.MethodEventSource has been deprecated
谢谢。