我可以在一个 Maven 项目中使用两个 Vaadin 版本吗(Vaadin7 和 Vaadin8)

Can I use two Vaadin versions in a single maven project(Vaadin7 and Vaadin8)

我有一个使用 Dropwizard 和 Vaadin7 的工作项目。 我需要在现有环境中使用 Vaadin8 而无需删除 vaadin7 代码。 我可以 运行 我的项目同时使用 Vaadin7 和 Vaadin8 版本吗? 由于我是 Vaadin 的新手,任何人都可以帮助我解决这个问题吗?

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-themes</artifactId>
    <version>7.5.10</version>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-client-compiled</artifactId>
    <version>7.5.10</version>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-client</artifactId>
    <version>7.5.10</version>
</dependency>

这是我当前的 vaadin 配置

你不能在 Maven 中使用同一个依赖的两个版本,它会使用第一个。

只要您没有在代码中使用 COMMUNITY ADD-ONS,将版本升级到 8 不会有问题。

我给你留下了一个很好的指南来学习如何升级版本: Guide to upgrade vaadin

如前所述,您不能在 Maven 中指定相同依赖项的两个版本,但在这种特殊情况下,您是否考虑过使用 Vaadin 8 Migrating to Vaadin 8 的兼容包?然后,您将能够使用 *.v7.* 导入从 Vaadin 7 框架访问所需的 类。如上面 link 中所述:

The only change to classes in the compatibility packages is the change in their classpath. All compatibility classes can be found under com.vaadin.v7.*. For example the compatibility TextField is available through the import import com.vaadin.v7.ui.TextField, given that the project dependencies have been set up to include the compatibility variants, as described in the previous section.

这不是您正在寻找的确切解决方案,但希望至少能有所帮助。

P.S。这个路径可能出现的问题是附加组件,如果它们没有被移植到 Vaadin8。那你就需要更新我们自己的依赖,替换掉不兼容的。