【问题标题】:How to use the latest version of Vaadin4Spring EventBus framework with Maven?如何在 Maven 中使用最新版本的 Vaadin4Spring EventBus 框架?
【发布时间】:2015-02-28 20:34:49
【问题描述】:

我有一个带有 Vaadin 的 Spring Boot 项目,我想集成 Vaadin4Spring EventBus 框架:

https://github.com/peholmst/vaadin4spring/tree/master/spring-vaadin-eventbus

作者说:

请注意,事件总线 API 在 0.0.5 版中发生了变化

但是,如果我在 pom.xml 中添加 Maven 依赖项:

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>LATEST</version>
    </dependency>
    ...

Maven 下载0.0.4.RELEASE 版本。我已尝试明确设置以下版本:

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5</version>
    </dependency>
    ...

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5.RELEASE</version>
    </dependency>
    ...

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5-SNAPSHOT</version>
    </dependency>
    ...

我还尝试将整个 Spring4Vaadin 插件设置为依赖项:

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>LATEST</version>
</dependency>
...


<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5</version>
</dependency>
...

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5-SNAPSHOT</version>
</dependency>    
...

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5.RELEASE</version>
</dependency>

但他们都没有工作。

基本上,我不能这样做:

 @Autowired
 EventBus.ApplicationEventBUs appEventBus;

 @Autowired
 EventBus.UIEventBus UIEventBus;
 ...

因为,正如 GitHub 上的 README.md 中所说:

请注意,事件总线 API 在版本 0.0.5 中发生了变化。现在起 on,您必须使用特定的声明来注入哪个事件总线 接口(以前,一切都是 EventBus 并且您使用了 注释以指定要获取的总线)。这种变化的原因 是

所以在版本0.0.4.RELEASE(Maven 认为是最新版本)中,内部接口ApplicationEventBusUIEventBus 没有定义。

那么,我怎样才能使用真正最新版本的插件呢?

【问题讨论】:

  • version 0.0.4.RELEASE 是 Maven Central 上最新的。
  • @khmarbaise 那么我该如何使用内部接口呢?下载源代码并编译?
  • 看起来这是唯一可能的原因,因为维护人员尚未在 Central 上发布新版本...可能在项目中给出问题提示可能会加快进程..跨度>
  • 是的,我确实像你说的那样,现在版本 0.0.5-SNAPSHOT 是要使用的版本。

标签: maven vaadin vaadin4spring


【解决方案1】:

将我在 vaadin 论坛中的答案也放在这里:

Vaadin 插件有一个很好的事件总线实现。检查https://github.com/peholmst/vaadin4spring/tree/master/samples/eventbus-sample

我已经使用启用了弹簧(不是弹簧启动)的 Vaadin 应用程序完成了这项工作,但我猜它可能在没有 Spring 的情况下也可以工作,简短的步骤: 1.添加如下依赖

<dependency>
    <groupId>org.vaadin.spring.addons</groupId>
    <artifactId>vaadin-spring-addon-eventbus</artifactId>
    <version>0.0.7.RELEASE</version>
</dependency>
  1. 将 EventBusConfiguration.class 导入 Spring 配置(如果 Spring Boot 与 @EnableAutoConfiguration 一起使用,则可能不需要)

  2. 在适当的事件总线中连接(检查可用的不同类型的文档),这里我使用一个适用于每个 UI 实例的总线:

    
    @Autowired
    private EventBus.UIEventBus uiEventBus;
    
  3. 根据需要发布事件,例如:

    
    uiEventBus.publish(this, new RefreshMainViewEvent(this, "Usage details updated"));
     
  4. 订阅其他组件类中的事件

    
    @PostConstruct
    public void afterPropertiesSet() {
    uiEventBus.subscribe(this, false); }
  5. 添加要对事件执行的操作(在同一类中):

    
    @EventBusListenerMethod
    public void closeSymmUsageWindow(RefreshMainViewEvent event) {
        logger.debug("Received {}", event);
        //blah
    }
    

【讨论】:

    猜你喜欢
    • 2015-05-02
    • 1970-01-01
    • 2013-01-04
    • 1970-01-01
    • 2015-05-08
    • 2012-06-05
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    相关资源
    最近更新 更多