安装 AspectJ Eclipse

Dr.*_*ath 1 java eclipse aspectj

我正在尝试开始面向方面的编程。我正在使用最新的 eclipse(当前为 2019 年 12 月)

public aspect Observer {

}
Run Code Online (Sandbox Code Playgroud)

这会导致错误 Syntax error on token "aspect", interface expected

根据https://www.eclipse.org/ajdt/downloads

我添加了 http://download.eclipse.org/tools/ajdt/43/update

作为 eclipse 的更新站点

Eclipse AspectJ 安装站点

但是eclipse告诉我有些部分无法安装

安装错误

看起来有些零件缺失了

无法完成安装,因为找不到一项或多项所需的项目。正在安装的软件:AspectJ 开发工具 2.2.3.e43x-RELEASE-20130627-0800 (org.eclipse.ajdt.feature.group 2.2.3.e43x-RELEASE-20130627-0800) 缺少要求:AspectJ 1.7.3.20130613144500-a ( org.aspectj.ajde 1.7.3.20130613144500-a) 需要 'osgi.bundle; org.eclipse.core.runtime.compatibility 0.0.0',但找不到无法满足依赖关系:来自:AspectJ Compiler 1.7.3.20130613144500-a(org.aspectj.feature.group 1.7.3.20130613144500-a)到:org. eclipse.equinox.p2.iu;org.aspectj.ajde [1.7.3.20130613144500-a,1.7.3.20130613144500-a] 无法满足依赖关系:来自:AspectJ 开发工具 2.2.3.e43x-RELEASE-20130627-0800 (org.eclipse.ajdt.feature.group 2.2. 3.e43x-RELEASE-20130627-0800) 至:org.eclipse.equinox.p2.iu;org.aspectj.feature.group [1.7.3.20130613144500-a,1.7.3.20130613144500-a]

如何让 Aspects 在 Eclipse 中运行?你能帮我一下吗?

Dud*_*Boy 5

您的问题是由于从 Eclipse 4.6 中删除org.eclipse.core.runtime.compatibility插件引起的。

请在此处阅读有关此问题的更多信息。

正确的解决办法是:

AspectJ从正确的下载链接安装。

最新更新到 Eclipse 4.10 的是: http ://download.eclipse.org/tools/ajdt/410/dev/update

另一个解决方案是:

  1. 卸载 Eclipse。

  2. 安装 Eclipse 4.3(与您的AspectJ版本匹配)。

  3. 重试 AspectJ 安装。

更复杂的解决方案是:

  1. 从Maven 存储库中找到并构建/提取org.eclipse.core.runtime.compatibilityjar 文件。

  2. org.eclipse.core.runtime.compatibilityjar 文件放入 Eclipse 插件目录中。

  3. eclipse在模式下运行--clean以重建并注册添加的插件。

  4. 重试 AspectJ 安装。

您可能会遇到更多缺少的依赖项org.eclipse.core.runtime.compatibility,最终将不得不加载所有相关的插件(长时间的努力)。