2012-04-25 118 views
1

所以我为我的Spring批处理程序设置了一个自定义的ApplicationEvent和ApplicationListener。我跟在部分3.13.2ApplicationListener不能用参数参数化?

这里说明here是我创建

import org.springframework.context.ApplicationEvent; 

public class DataReaderEvent extends ApplicationEvent { 

    private final String progress; 
    private final String text; 

    public DataReaderEvent(Object source, String progress, String text) { 
     super(source); 
     this.progress = progress; 
     this.text = text; 
    } 

    public String getProgress() { 
     return progress; 
    } 

    public String getText() { 
     return text; 
    } 

} 

的了ApplicationEvent而我ApplicationListener

import org.springframework.context.ApplicationListener; 

public class DataReaderNotifier implements ApplicationListener<DataReaderEvent> { 

    private String progress; 
    private String text; 


    @Override 
    public void onApplicationEvent(DataReaderEvent event) { 
     this.progress = event.getProgress(); 
     this.text = event.getText(); 
    } 

    public String getProgress() { 
     return progress; 
    } 

    public String getText() { 
     return text; 
    } 
} 

我遇到的问题是了ApplicationListener抱怨我尝试要做 ApplicationListener < DataReaderEvent>

它说, “ApplicationListener类型不是通用的;它不能与参数进行参数DataEventReader”

我不明白为什么会是这样,因为我觉得我跟着例子非常密切,如果任何人有他们将不胜感激的任何想法。

回答