0
的基於JUnit測試我使用ManagedExecutorService併發在我的代碼是這樣的:如何使用注射資源從服務器(如ManagedExecutorService)春季
@Resource
private ManagedExecutorService defaultManagedExecutorService;
它工作正常,如果我建立他們和部署他們我服務器,因爲我引用服務器上的資源ManagedExecutorService:
<managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" core-threads="5" max-threads="25" keepalive-time="5000"/>
但我有Junit基於Spring的測試。爲了運行這個測試,我不需要任何服務器。所以我得到以下異常:
Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.enterprise.concurrent.ManagedExecutorService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(mappedName=, shareable=true, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER, lookup=)}
看來春天無法從服務器找到我的資源。
我現在能做什麼?
謝謝!
非常感謝! – Manuela