NoSuchMethodError - CDI fireAsync
NoSuchMethodError - CDI fireAsync
我正在尝试使用 CDI 2 附带的新 fireAsync 方法。我 运行 使用 Wildfly 10.1.0。
我总是通过调用 fireAsnyc() 方法得到一个错误:
javax.servlet.ServletException
Caused by: java.lang.NoSuchMethodError: javax.enterprise.event.Event.fireAsync(Ljava/lang/Object;)Ljava/util/concurrent/CompletionStage;
这是我的代码:
@Inject Event<Customer > customerEvent ;
public String save() {
Customer customer = new Customer("Max", "Smith");
customerEvent.fireAsync(customer);
return "something";
}
还有我的pom.xml:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
Wildfly 10.1 使用的是 Java EE 7,它附带 CDI 1.2/Weld 2.3。您可以将它升级到 CDI 2,如果您查看 the weld blog
可以找到可用的补丁
我正在尝试使用 CDI 2 附带的新 fireAsync 方法。我 运行 使用 Wildfly 10.1.0。 我总是通过调用 fireAsnyc() 方法得到一个错误:
javax.servlet.ServletException
Caused by: java.lang.NoSuchMethodError: javax.enterprise.event.Event.fireAsync(Ljava/lang/Object;)Ljava/util/concurrent/CompletionStage;
这是我的代码:
@Inject Event<Customer > customerEvent ;
public String save() {
Customer customer = new Customer("Max", "Smith");
customerEvent.fireAsync(customer);
return "something";
}
还有我的pom.xml:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
Wildfly 10.1 使用的是 Java EE 7,它附带 CDI 1.2/Weld 2.3。您可以将它升级到 CDI 2,如果您查看 the weld blog
可以找到可用的补丁