Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse:javax.annotation PostConstruct未被调用_Java_Eclipse_Eclipse Plugin_Fedora 29 - Fatal编程技术网

Eclipse:javax.annotation PostConstruct未被调用

Eclipse:javax.annotation PostConstruct未被调用,java,eclipse,eclipse-plugin,fedora-29,Java,Eclipse,Eclipse Plugin,Fedora 29,我正在使用Fedora29,并尝试通过创建一个新的插件项目来尝试一个简单的插件示例,并使用了“使用4.xapi查看贡献”模板 我已提供以下系统属性: -Dorg.eclipse.e4.core.di.debug=true 在eclipse下的VM参数中 启用该调试后,我收到以下消息: !MESSAGE Possbible annotation mismatch: method "public void hello.parts.SampleView.createPartControl(org.e

我正在使用Fedora29,并尝试通过创建一个新的插件项目来尝试一个简单的插件示例,并使用了“使用4.xapi查看贡献”模板

我已提供以下系统属性:

-Dorg.eclipse.e4.core.di.debug=true
在eclipse下的VM参数中

启用该调试后,我收到以下消息:

!MESSAGE Possbible annotation mismatch: method "public void hello.parts.SampleView.createPartControl(org.eclipse.swt.widgets.Composite)" annotated with "javax.annotation-api:1.2.0:javax.annotation.PostConstruct" but was looking for "javax.annotation.PostConstruct [via bootstrap classloader]"
此错误消息的含义是什么?我如何解决它

下面是包含PostConstruct注释的eclipse插件示例的片段

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class SampleView {
    private Label myLabelInView;

    @PostConstruct
    public void createPartControl(Composite parent) {
        System.out.println("Enter in SampleE4View postConstruct");

        myLabelInView = new Label(parent, SWT.BORDER);
        myLabelInView.setText("This is a sample E4 view");

    }
编辑:

Manifest.mf文件:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Hello
Bundle-SymbolicName: hello;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: javax.inject,
 org.eclipse.osgi,
 org.eclipse.jface,
 org.eclipse.e4.ui.model.workbench,
 org.eclipse.e4.ui.di,
 org.eclipse.e4.ui.services,
 org.eclipse.e4.core.di.annotations
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: hello
Import-Package: javax.annotation
编辑2:

在检查javax.annotation的JAR(它被称为javax.annotation-api,而不是javax.annotation…)后,我发现它们有一个指向glassfish实现的符号链接:

/usr/lib/eclipse/plugins/javax.annotation-api_1.2.0.jar -> /usr/share/java/glassfish-annotation-api.jar
/usr/lib/eclipse/plugins/javax.el-api_3.0.0.jar -> /usr/share/java/glassfish-el-api.jar
/usr/lib/eclipse/plugins/javax.inject_1.0.0.v20091030.jar -> /usr/share/java/atinject.jar
/usr/lib/eclipse/plugins/javax.servlet-api_3.1.0.jar -> /usr/share/java/glassfish-servlet-api.jar
/usr/lib/eclipse/plugins/javax.servlet.jsp_2.3.2.b01.jar -> /usr/share/java/glassfish-jsp-api/javax.servlet.jsp-api.jar

似乎导入包选择了错误的插件。还应该有一个正确的
javax.annotation
插件。尝试将
javax.annotation
添加到
Require Bundle
列表中,以强制使用:

Require-Bundle: javax.inject,
 javax.annotation,
 org.eclipse.osgi,
 org.eclipse.jface,
 org.eclipse.e4.ui.model.workbench,
 org.eclipse.e4.ui.di,
 org.eclipse.e4.ui.services,
 org.eclipse.e4.core.di.annotations

似乎导入包选择了错误的插件。还应该有一个正确的
javax.annotation
插件。尝试将
javax.annotation
添加到
Require Bundle
列表中,以强制使用:

Require-Bundle: javax.inject,
 javax.annotation,
 org.eclipse.osgi,
 org.eclipse.jface,
 org.eclipse.e4.ui.model.workbench,
 org.eclipse.e4.ui.di,
 org.eclipse.e4.ui.services,
 org.eclipse.e4.core.di.annotations

在春季,您需要在应用程序上下文中添加这一行,我希望能帮助您

<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />

在春季,您需要在应用程序上下文中添加这一行,我希望能帮助您

<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />


向我们展示插件inDo的MANIFEST.MF您还有一个
javax.annotation\u xxxx
插件吗?尝试将
javax.annotation
添加到
Require Bundle
列表中,以强制执行正确的插件。好的,我试试看。向我们展示插件的MANIFEST.MF。您还有
javax.annotation\u xxxx
插件吗?尝试将
javax.annotation
添加到
Require Bundle
列表中,以强制执行正确的插件。好的,我试试看。是的,这似乎确实有效,这是一个好的做法吗?javax.annotation应该是require包而不是import包吗?在windows和其他linux发行版上使用导入确实有效。总是需要捆绑包安全吗?我不确定。几年前发布的版本中有一些更改,只对javax.inject和javax.annotation使用导入包,但在本例中,这显然是错误的。是的,这似乎确实有效,这是一个好的做法吗?javax.annotation应该是require包而不是import包吗?在windows和其他linux发行版上使用导入确实有效。总是需要捆绑包安全吗?我不确定。在几次发布之前,对javax.inject和javax.annotation仅使用导入包进行了一些更改,但在本例中,这显然是错误的。