new > maven project
选择工作目录,使用默认工作目录
选择原型
如果没有vaadin原型,点击Add Archetype
输入项目参数
点击finish后项目结构如下
Pom文件报错,描述如下:
Plugin execution not covered by lifecycle configuration: com.vaadin:vaadin-maven-plugin:7.1.0:update-theme (execution: default, phase: generate-sources) line147 Maven Project Build Lifecycle Mapping Problem
可以看出lifecycle configuration中缺少update-theme的配置
解决:
Line 191 增加 <goal>update-theme</goal>
网上参考:http://blog.csdn.net/xxd851116/article/details/25197373
Finish后,pom文件会有报错
解决Maven报Plugin execution not covered by lifecycle configuration
解决办法
官网给出解释及解决办法:http://wiki.eclipse.org/M2E_plugin_execution_not_covered
这里有人说下面这样也可以解决, 即 <plugins> 标签外再套一个 <pluginManagement> 标签,我试验是成功的:
http://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin
<build>
<pluginManagement>
<plugins>
<plugin> ... </plugin>
<plugin> ... </plugin>
....
</plugins>
</pluginManagement>
</build>
Maven install
右键项目,run as –>maven install
没有问题的话会提示BUILD SUCCESS
Maven jetty:run
调用 Jetty 插件,目标在 Jetty Servlet 容器中启动 web 应用
Apply 然后 Debug
访问
代码
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Button button = new Button("Click Me");
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label("Thank you for clicking"));
}
});
layout.addComponent(button);
}
组件功能
标题设定:
Button button = new Button("Click Me");
设置按钮标题为click me
给按钮添加描述信息:
button.setDescription("This is the tooltip");
富文本描述
激活与禁用
button.setEnabled(true)
button.setEnabled(false)
图标:
button.setIcon(new ThemeResource("mchine.png"));
访问theme文件夹下的资源