我正在尝试使用 Esper 运行一个简单的测试(第 14 章,http://dl.e-book-free.com/2013/07/activiti_in_action.pdf)。代码非常简单:
public class EventLengthWindowTest {
public class LoanRequestEvent {
public int amount =2;
public LoanRequestEvent(int a){
amount += a;
}
}
private int sumAmount = 0;
@Test
public void testEventLengthWindow() {
Configuration configuration = new Configuration();
configuration.addEventType(LoanRequestEvent.class);
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
EPAdministrator admin = epService.getEPAdministrator();
EPStatement epStatement = admin.createEPL("select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)");
...
}
我收到有关 EPL 部分的错误消息:
"select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)"
它说:
com.espertech.esper.client.EPStatementException: Error starting statement: Failed to validate select-clause expression 'sum(amount)': Property named 'amount' is not valid in any stream [select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)]
任何想法为什么会发生这种情况?