java - 从 v22 升级到 v24 后,某些 Vaadin 组件未呈现

标签 java vaadin

从 Vaadin 22 升级到 24 后,一些内置组件(例如组合框或网格)无法在与 Vaadin 22 一起正常运行的应用程序中显示。 我们正在使用:

  • Vaadin 24.1.1,具有 npn、Vite 和生产模式。

  • Spring Boot 3.1.1

    应用程序的日志显示以下消息:

2023-07-07T10:58:56.045+02:00 ERROR 3404 --- [http-nio-9012-exec-9] c.v.flow.component.internal.UIInternals  : The component class com.vaadin.flow.component.combobox.ComboBox includes '@vaadin/combo-box/src/vaadin-combo-box.js' but this file was not included when creating the production bundle. The component will not work properly. Check that you have a reference to the component and that you are not using it only through reflection. If needed add a @Uses(ComboBox.class) where it is used.
2023-07-07T12:55:41.395+02:00 ERROR 19744 --- [http-nio-9012-exec-2] c.v.flow.component.internal.UIInternals  : The component class com.vaadin.flow.component.details.Details includes '@vaadin/details/src/vaadin-details.js' but this file was not included when creating the production bundle. The component will not work properly. Check that you have a reference to the component and that you are not using it only through reflection. If needed add a @Uses(Details.class) where it is used.

并且生成页面的源代码有一个空标签vaadin-combo-box:

<vaadin-combo-box></vaadin-combo-box>

我们已经多次删除了 Vaadin 生成的 node_modules 和 fronted 目录,但没有任何变化。有没有人可以帮助我们?

最佳答案

我们使用如下代码动态注册路由: RouteConfiguration.forSessionScope().setRoute("home", HomeView.class, MainLayout.class);

哪里MainLayout.class扩展 AppLayout

问题在于 HomeView.class 中使用的组件且未用于 MainLayout.class不显示。

我们必须添加注释 @UsesMainLayout.class与组件,例如:

@Uses(ComboBox.class)

现在所有组件都正确显示了。

其他解决方案是使用属性 <optimizeBundle>false</optimizeBundle>build-frontend pom.xml 的目标

这种行为非常奇怪,因为在 Vaadin 22 中,应用程序在没有 @Uses 的情况下工作正常。注释。

关于java - 从 v22 升级到 v24 后,某些 Vaadin 组件未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76636685/

相关文章:

java - Java 中存在冲突作用域的变量声明。我读到的一段文字中这句话的含义是什么?

java - 无法解决 Vaadin 7.6.2 与 Ivy 的依赖关系

Vaadin 流 : setting the title

Vaadin excel 导出与转换器值

spring - 为什么 Vaadin @Autowired 服务返回 null ?

java - 如何在struts2 启动时将一些数据库值设置为应用程序范围?

java - 为什么预处理器不像 C 和 C++ 那样是 Java 程序的一部分?

java - 如何访问数组的元素并且该数组是 ArrayList 的元素?

java - 在矩形内绘制基于图 block 的椭圆

filter - Vaadin Grid - 具有延迟加载的多个过滤器