我正在使用焊接 1.0。这是我的情况:我有一个类实例化一个 Weld 容器,它试图实例化一个类StartupShutdown
:
public static void main(String[] args) {
WeldContainer weld;
weld = new Weld().initialize();
StartupShutdown startupShutdown = weld.instance().select(StartupShutdown.class).get();
}
这是我的课StartupShutdown
:
public class StartupShutdown {
@Inject
public StartupShutdown(LoggingFileHandler loggingFileHandler) {
}
}
我得到了这个例外:
Exception in thread "main" org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [class fr.easycompany.easywrite.processes.StartupShutdown]; Bindings: [QualifierInstance{annotationClass=interface javax.enterprise.inject.Default, values={}, hashCode=2062316647}]
at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:728)
at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:102)
at fr.easycompany.easywrite.EasyWrite.main(EasyWrite.java:18)
当我在StartupShutdown
构造函数中删除参数时,它可以工作。
仅供参考,这是我的LoggingFileHandler
:
public class LoggingFileHandler extends FileHandler {
@Inject
public LoggingFileHandler(LoggingFormatter formatter) throws IOException, SecurityException {
super("");
this.setFormatter(formatter);
}
}
我的构造函数中的这个参数有什么问题?