---
title: "vaadin8+springboot开发web应用（二 创建springboot+vaadin项目）"
author: "cooperay"
date: "2018-05-11T18:20:43Z"
tags: []
categories: ["Web前端"]
slug: "vaadin8-springboot-web-springboot-vaadin"
draft: false
lastmod: "2018-05-11T18:20:43Z"
id: 2422576
url: "https://cooperay.iteye.com/blog/2422576"
---

安装完spring tools 与vaadin插件后 可通过新建springboot项目的方式创建 springboot+vaadin项目

 

new -&gt; spring start project 

 

创建项目过程中选择web 和 vaadin 支持  
![](http://dl2.iteye.com/upload/attachment/0129/7957/87d487d3-d1fd-3ffc-b44c-2c21fd6d0022.png)

 

项目创建完成后maven 会 自动加载vaadin所需jar包 vaadin-\*.jar

 

 

创建 UI 界面

在spring boot Application 相同位置新建 SystemUI.java 名称随便取

![](http://dl2.iteye.com/upload/attachment/0129/7959/5416a8ff-63a0-3971-9326-08eb9f28c8b7.png)  
 

```
@SpringUI
public class SystemUI extends UI {
	private static final long serialVersionUID = 1L;

	@Override
	protected void init(VaadinRequest request) {
		Button button = new Button("Click Me");
		button.addClickListener(e -> {
			Notification.show("Hello vaadin 8", Type.WARNING_MESSAGE);
		});
		
		VerticalLayout content = new VerticalLayout();
		content.addComponent(button);
		setContent(content);
	}

}
```

 使用SpringUI注解标识该类为一个vaadin的ui

代码中  将UI设置为纵向布局 并添加一个按钮，点击按钮 显示一个警告通知。

 

运行该项目 run as springboot app

浏览器访问 localhost:8080

![](http://dl2.iteye.com/upload/attachment/0129/7961/b87663e3-7559-38c2-a0ad-bd23d67c4409.png)  
 

第一个vaadin+springboot项目完成