Xtext - The type com.google.inject.Inject is not on the classpath

拥有回忆 提交于 2019-12-24 15:04:32

问题


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)

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?


回答1:


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



来源:https://stackoverflow.com/questions/34121018/xtext-the-type-com-google-inject-inject-is-not-on-the-classpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!