首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Maven中使用Vaadin4Spring EventBus框架的最新版本?

如何在Maven中使用Vaadin4Spring EventBus框架的最新版本?
EN

Stack Overflow用户
提问于 2015-02-28 20:34:49
回答 1查看 1.1K关注 0票数 0

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

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

作者说:

请注意,事件总线API在0.0.5版本中发生了更改

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

代码语言:javascript
复制
    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>LATEST</version>
    </dependency>
    ...

Maven下载0.0.4.RELEASE版本。我试图显式设置以下版本:

代码语言:javascript
复制
    ...
    <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插件设置为依赖项:

代码语言:javascript
复制
<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>

但两者都不起作用。

基本上我不能这样做:

代码语言:javascript
复制
 @Autowired
 EventBus.ApplicationEventBUs appEventBus;

 @Autowired
 EventBus.UIEventBus UIEventBus;
 ...

因为,正如README.md on GitHub中所说的那样:

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

因此,在版本0.0.4.RELEASE ( Maven视为最新版本)中,没有定义内部接口ApplicationEventBusUIEventBus

那么,我如何才能使用真正的最新版本的这句话呢?

EN

回答 1

Stack Overflow用户

发布于 2016-12-29 11:47:49

我把答案放进了穹顶论坛,在这里也是这样:

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

我使用了一个启用了spring (而不是spring )的Vaadin应用程序来完成这个任务,但是如果没有Spring,它也可以工作--我猜,下面的步骤很简单: 1.添加以下依赖项

代码语言:javascript
复制
<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与@EnableAutoConfiguration一起使用,则可能不需要)
  2. 在适当的事件总线中连接(检查不同类型可用的加法),这里我使用的是每个UI实例中的一个: @自动头发的私人EventBus.UIEventBus uiEventBus;
  3. 按要求发布事件(如:

UiEventBus.publish(此,新RefreshMainViewEvent(此,“使用细节更新”));

  1. 订阅另一个组件类中的事件

@PostConstruct公共空afterPropertiesSet() { uiEventBus.subscribe(this,false);}

  1. 添加要对事件执行的操作(在这里的同一个类中):

@EventBusListenerMethod (RefreshMainViewEvent事件){logger.debug(“接收到的{}",事件);//blah }

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28786579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档