默认包“。” Import-Package语法不允许

Pet*_*ter 5 java osgi intellij-idea aem

尝试使用Intellij IDEA运行@ org.junit.Test。

这是一个OSGi套件,当点击Run'testMyTest'

获取以下异常:

Error:osgi: [b2b-bundle] The default package '.' is not permitted by the Import-Package syntax. 
    This can be caused by compile errors in Eclipse because Eclipse creates 
    valid class files regardless of compile errors.
    The following package(s) import from the default package null
Run Code Online (Sandbox Code Playgroud)

有人可以就这个例外情况发表看法吗?

谢谢彼得

Hem*_*ant 7

您可能没有将类放在包中。

添加

package your_package_name;
Run Code Online (Sandbox Code Playgroud)

在 .java 文件的顶部,你应该很好。

PS:根据您的包名称,您可能还需要将文件移动到其他位置


cod*_*ick 2

根据我对 OSGi 库的理解,.class 文件不应该是 b/c 这个库的结构方式,根包中有 deps。

查看博客可了解更多详细信息。