Xtext - com.google.inject.Inject 类型不在类路径中 [英] Xtext - The type com.google.inject.Inject is not on the classpath

查看:30
本文介绍了Xtext - com.google.inject.Inject 类型不在类路径中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JvmModelInferrer.xtend 中使用以下代码生成 Java 类

I am using the following code in JvmModelInferrer.xtend to generate a Java class

@Inject extension JvmTypesBuilder

def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
    acceptor.accept(element.toClass(element.name)) [
        annotations += annotationRef(Inject);
    ]
}

当我尝试运行整个项目时,出现以下错误.

When I try to run the whole project, I get the following error.

5226 [main] ERROR org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder  - Error initializing JvmElement
java.lang.IllegalArgumentException: The type com.google.inject.Inject is not on the classpath.
    at org.eclipse.xtext.xbase.jvmmodel.JvmAnnotationReferenceBuilder.annotationRef(JvmAnnotationReferenceBuilder.java:83)
    at org.eclipse.xtext.xbase.jvmmodel.JvmAnnotationReferenceBuilder.annotationRef(JvmAnnotationReferenceBuilder.java:60)
    at org.example.statemodel.jvmmodel.StatemodelJvmModelInferrer.lambda$5(StatemodelJvmModelInferrer.java:60)
    at org.example.statemodel.jvmmodel.StatemodelJvmModelInferrer$$Lambda$8/864303682.apply(Unknown Source)
    at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.initializeSafely(JvmTypesBuilder.java:206)
    at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toField(JvmTypesBuilder.java:588)

我尝试将相应的依赖项 com.google.inject.source;bundle-version="3.0.0" 添加到 plugin.xml.我仍然遇到同样的错误.我们如何解决这个问题?

I tried adding the corresponding dependency com.google.inject.source;bundle-version="3.0.0" to plugin.xml. Still I am getting the same error. How can we solve this issue?

推荐答案

您必须确保 Guice 位于包含您的 DSL 文件的项目的类路径中.

You have to make sure that Guice is on the classpath of the project, that contains your DSL file.

这篇关于Xtext - com.google.inject.Inject 类型不在类路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆