E4 不调用我的@PostConstruct-Method

E4 doesn´t invoke my @PostConstruct-Method

我在将 E3-RCP-Application 迁移到 E4 时遇到问题。 我有 3 个部分。 2 使用 Lars Vogel (http://www.vogella.com/tutorials/EclipseRCP/article.html#plugin_creatinge4 "Using the SWT power widget") 的样本内容来测试并与我的部分进行比较。

长话短说(er):应该创建视图内容的方法,标有@PostConstruct,不会被调用,但SampleContent 的@PostConstruct 会被调用。那会有什么原因呢? 调用 MyView 的构造函数。

我的视图结构如下:

Many Imports

public class MyView1 implements IRefreshableView, ISomeListener {

a lot of fields, some are injected...

public MyView1()  {
        reference to the Activator-Class to get some item.
    }

@PostConstruct
public void createControls(Composite parent) {
        createViewToolbar();``

and much more Part Creation stuff that won´t be invoked...

}

much more methods
@Focus
    public void setFocus() {
        if (treeViewer.getTree().isVisible()) {
            treeViewer.getTree().setFocus();
        } else {
            mainForm.setFocus();
        }
    }

}

new class definition in the same file. 

END

很抱歉没有发布整个代码,它有 1000 行长:/

我在 Win7 上使用 Mars 4.5.1

@PostConstruct 未能 运行 的一个原因是直接注入代码无法找到注入到字段(或注入的构造函数)中的对象。如果发生这种情况,注入器只会记录错误并停止。

错误记录在工作区“.metadata”目录下的“.log”文件中。