【发布时间】:2011-04-20 16:26:07
【问题描述】:
我正在尝试做简单的事情。在 CDI 中注入合格的String(或File)。
所以我有一个限定符:
@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD,METHOD,PARAMETER,TYPE})
@Qualifier
public @interface FilesRepositoryPath {}
我有一个制作人:
public class FilesRepositoryPathProducer {
@Produces
@FilesRepositoryPath
public String getRepositoryDirectory() {
return "path.taken.from.configuration";
}
}
我正在尝试使用它:
@ApplicationScoped
public class FilesRepository {
@Inject
public FilesRepository(@FilesRepositoryPath String filesDirectory) {
//Do some stuff
}
}
但是,WELD 无法实例化此 bean。我遇到了一个例外:
org.jboss.arquillian.impl.event.FiredEventException: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001410 The injection point [field] @Inject private za.co.fnb.commercial.dms.file.FilesRepositoryBeanTest.repo has non-proxyable dependencies
我知道String 是不可代理的,但是为什么 WELD 想要创建一个代理呢?它有 @Dependent 范围,所以 AFAIK 它不应该创建代理。我怎样才能让它发挥作用?
【问题讨论】:
-
可以发帖
FilesRepositoryBeanTest吗? -
在 Weld 中提出问题。根据规范,代码似乎没问题。
-
看看这里:stackoverflow.com/questions/7583871/…,好像是类似的问题
标签: cdi jboss-weld