Java EclipseDI不创建用Created注释的自定义对象
我正在开发一个基于4.4 Luna版本的Eclipse RCP应用程序 我有以下课程:Java EclipseDI不创建用Created注释的自定义对象,java,dependency-injection,eclipse-rcp,e4,Java,Dependency Injection,Eclipse Rcp,E4,我正在开发一个基于4.4 Luna版本的Eclipse RCP应用程序 我有以下课程: public class NewProjectDialog extends TitleAreaDialog { @Inject private ProjectManager projectManager; // some code } 及 当我运行应用程序并打开NewProjectDialog时,会引发以下异常: org.eclipse.e4.core.di.InjectionException: o
public class NewProjectDialog extends TitleAreaDialog {
@Inject
private ProjectManager projectManager;
// some code
}
及
当我运行应用程序并打开NewProjectDialog
时,会引发以下异常:
org.eclipse.e4.core.di.InjectionException: org.eclipse.e4.core.di.
InjectionException: Unable to process "NewProjectDialog.projectManager":
no actual value was found for the argument "ProjectManager".
除了
@createable
注释之外,当Eclipse DI在上下文中找不到该类时,我必须做更多的事情来使它实例化该类吗?我也面临同样的问题,并且greg-449已经给出的答案在问题的注释部分是正确的。是的,在注入/创建这些对象的字段时出现问题。是不是ProjectManager
在另一个插件中?如果是这样的话,包含它的包必须在插件的导出包列表中。不,它们都在同一个插件中,只是在不同的包中NewProjectDialog
是通过ContextInjectionFactory
创建的,但我想这并不重要。ProjectManager是否有一个public
构造函数?看起来需要一个(如果有任何参数,则使用@Inject)。ProjectManager
不包含任何构造函数,但包含两个注入字段。我已尝试使用@Inject
注释创建默认构造函数,但仍有相同的异常。可能是由于在上下文中找不到注入的字段而出现问题。
org.eclipse.e4.core.di.InjectionException: org.eclipse.e4.core.di.
InjectionException: Unable to process "NewProjectDialog.projectManager":
no actual value was found for the argument "ProjectManager".