我想在spring应用程序中使用ManagedExecutorService。然而春天不能注射它。低于错误。
引起: org.springframework.beans.factory.NoSuchBeanDefinitionException:没有 合格的bean类型 找到[javax.enterprise.concurrent.ManagedExecutorService] 依赖:预计至少有1个bean有资格成为autowire 这种依赖的候选人。依赖注释: {@ javax.annotation.Resource(shareable = true,lookup =,name =, description =,authenticationType = CONTAINER,type = class java.lang.Object,mappedName =)}
更新
我更新代码源代码如下,以注入ManagedExecutorService。
@Bean(name = "commonRestThreadExecutor")
public ManagedExecutorService commonRestThreadExecutor() throws NamingException {
return (ManagedExecutorService) new InitialContext().lookup("java:comp/DefaultManagedExecutorService");
}
@Autowired
private ManagedExecutorService commonRestThreadExecutor;
但现在我收到了错误
引起:javax.naming.NameNotFoundException:名称> [DefaultManagedExecutorService]未绑定在此Context中。无法找到> [DefaultManagedExecutorService]。
答案 0 :(得分:0)
以下声明解决了我的问题,
@Resource(name = "default", lookup = "java:jboss/ee/concurrency/executor/default")
private ManagedExecutorService managedExecutorService;