我如何修复’com.vaadin.DefaultWidgetSet’不包含com.vaadin.addon.charts.Chart的实现

通过在Eclipse / STS中使用“Spring Stater Project”,我能够快速启动并运行Vaadin项目。 我想通过Vaadin-Addon将图表添加到项目中。 我谷歌搜索试图找到如何正确添加和使用Vaadin Chart插件到项目。 但我很困惑,因为有很多“指南/教程”,但很多不是春季启动或他们已经过时或部分。

所以我正在寻找Vaadin-SpringBoot-VaadinChart-AddOn的完整指南/教程。

这是我到目前为止:

—- Pom文件—-

  4.0.0 com.aci oversight2 0.0.1-SNAPSHOT jar oversight2 Oversite  org.springframework.boot spring-boot-starter-parent 1.2.5.RELEASE     UTF-8 1.8   <!--  --> <!-- com.vaadin --> <!-- vaadin-spring-boot --> <!-- 1.0.0 --> <!--  -->  com.vaadin vaadin-spring-boot-starter 1.0.0.beta3   org.springframework.boot spring-boot-starter-test test   com.vaadin.addon 2.0.0 vaadin-charts      com.vaadin vaadin-bom 7.4.5 pom import       org.springframework.boot spring-boot-maven-plugin      vaadin-addons http://maven.vaadin.com/vaadin-addons    

—- Java代码—-

 public class BasicBarChart extends AbstractVaadinChartExample { @Override public String getDescription() { return "Basic bar"; } @Override protected Component getChart() { Chart chart = new Chart(ChartType.BAR); Configuration conf = chart.getConfiguration(); conf.setTitle("Historic World Population by Region"); conf.setSubTitle("Source: Wikipedia.org"); XAxis x = new XAxis(); x.setCategories("Africa", "America", "Asia", "Europe", "Oceania"); x.setTitle((String) null); conf.addxAxis(x); YAxis y = new YAxis(); y.setMin(0); Title title = new Title("Population (millions)"); title.setVerticalAlign(VerticalAlign.HIGH); y.setTitle(title); conf.addyAxis(y); Tooltip tooltip = new Tooltip(); tooltip.setFormatter("this.series.name +': '+ this.y +' millions'"); conf.setTooltip(tooltip); PlotOptionsBar plot = new PlotOptionsBar(); plot.setDataLabels(new Labels(true)); conf.setPlotOptions(plot); Legend legend = new Legend(); legend.setLayout(LayoutDirection.VERTICAL); legend.setHorizontalAlign(HorizontalAlign.RIGHT); legend.setVerticalAlign(VerticalAlign.TOP); legend.setX(-100); legend.setY(100); legend.setFloating(true); legend.setBorderWidth(1); legend.setBackgroundColor("#FFFFFF"); legend.setShadow(true); conf.setLegend(legend); conf.disableCredits(); List series = new ArrayList(); series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2)); series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6)); series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34)); conf.setSeries(series); chart.drawChart(conf); return chart; } } @SpringUI @VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class) public class MyVaadinUI extends UI { @Override protected void init(VaadinRequest vaadinRequest) { setContent(new BasicBarChart()); } } 

我创建了30天的AGPL许可证密钥

有些网站说我需要一个gwt.xml文件,或者这可以通过注释完成

有些网站说我需要“重新编译你的widgetset”,这意味着我需要在我的pom文件中添加一些插件。

其他网站说我需要一个web.xml,但只需运行spring-boot-vaadin Vaadin应用程序。

当我运行代码时,我得到:

Widgetset’com.vaadin.DefaultWidgetSet’不包含com.vaadin.addon.charts.Chart的实现。 检查其组件连接器的@Connect映射,widgetsets GWT模块描述文件并重新编译您的widgetset。 如果您下载了vaadin附加软件包,则可能需要参考附加说明。

该过程与所有加载项相同。 对于简单的应用程序,您只需要核心小部件,并可以使用“DefaultWidgetSet”。 您需要在项目中使用“ApplicationWidgetset”,它将核心的基本客户端组件实现与您在项目中使用的所有附加组件相结合。

这些是使用TouchKit附加组件的示例中的说明,但过程基本相同:

  • 使用cdn.virit.in的简单选项:
    • 将插件添加到pom.xml
    • 将生成的servletfilter添加到您的配置https://github.com/mstahv/vaadin-spring-touchkit/blob/master/src/main/java/org/vaadin/tkspring/Application.java#L20-L25
  • 标准解决方案
    • 将vaadin-maven-plugn添加到pom.xml
    • 将@Widgetset注释添加到UI类