Test 메서드를 실행하려고하면 프로젝트를 성공적으로 배포하고 실행할 수 있습니다. 이 일반적인 오류가 발생했습니다WELD-001408 한정자가있는 [...] 유형의 만족하지 못하는 종속성 [@Named]
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [AutomatedTellerMachine] with qualifiers [@Named] at injection point [[field] @Named @Inject private advocacy.TestExample.automatedTellerMachine]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:274)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:243)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:126)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:345)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:330)
..
..
또한 여기에서 비슷한 질문을 읽지 않았습니다. 나는 여기서 cdi-tutorial에서 의존성 주입에 대한 helloword 예제를 읽었으며 그 후에는 arquillian-tutorial을 읽기 시작했습니다.
AutomatedTellerMachine.java
package advocacy;
import java.math.BigDecimal;
public interface AutomatedTellerMachine {
public void deposit(BigDecimal bd);
public void withdraw(BigDecimal bd);
}
AutomatedTellerMachineImpl.java
package advocacy;
import javax.inject.Inject;
import javax.inject.Named;
import java.math.BigDecimal;
@Named("atm")
public class AutomatedTellerMachineImpl implements AutomatedTellerMachine {
@Inject
@Named("jsonRestAtmTransport")
private ATMTransport atmTransport;
...
}
내 시험 방법은 같다;
TestExample.java
package advocacy;
imports..
@RunWith(Arquillian.class)
public class TestExample {
@Inject
@Named("atm")
private AutomatedTellerMachine automatedTellerMachine;
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "dependecy-injection.war")
.addClasses(AutomatedTellerMachine.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "META-INF/beans.xml");
}
@Test
public void test() {
automatedTellerMachine.deposit(new BigDecimal(12.99));
}
}
내 beans.xml 환경은 here