ITeye博客

vaadin8+springboot开发web应用(二 创建springboot+vaadin项目)

cooperay · 2018-05-11 18:20 · vaadin8 · Web前端 · Markdown

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

 

new -> spring start project 

 

创建项目过程中选择web 和 vaadin 支持

 

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

 

 

创建 UI 界面

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


 

@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


 

第一个vaadin+springboot项目完成

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。