EMF-Project上的Maven编译失败

时间:2015-03-31 14:46:40

标签: java eclipse maven emf

我必须使用EMF项目并且需要使用另一个包中的一些类。 当我尝试用maven构建生成的代码时,我得到了这个失败:

[INFO] 6 errors
[INFO] -------------------------------------------------------------
[INFO]------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]------------------------------------------------------------------------
[INFO] Total time: 2.844 s
[INFO] Finished at: 2015-03-31T16:25:42+02:00
[INFO] Final Memory: 14M/163M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project datamodel: Compilation failure:
 Compilation failure:
[ERROR] /C:/.../util/ModelSwitch.java:[20,34] cannot find symbol
[ERROR] symbol:   class Switch
[ERROR] location: package org.eclipse.emf.ecore.util
[ERROR] /C:/.../util/ModelSwitch.java:[85,38] cannot find symbol
[ERROR] symbol: class Switch
[ERROR] /C:/.../util/ModelSwitch.java:[114,9] method does not override or implement a method from a supertype
[ERROR] /C:/.../util/ModelSwitch.java:[126,9] method does not override or implement a method from a supertype
[ERROR] /C:/.../util/ModelSwitch.java:[1341,9] method does not override or implement a method from a supertype
[ERROR] /C:/.../util/ModelAdapterFactory.java:[365,35] method doSwitch in class com...util.ModelSwitch<T1> cannot be applied to given types;
[ERROR] required: int,org.eclipse.emf.ecore.EObject
[ERROR] found: org.eclipse.emf.ecore.EObject
[ERROR] reason: actual and formal argument lists differ in length

所有库都已导入并在pom中,但生成的ModelSwitch类仍然存在问题。

这个错误和事实,Eclipse Luna是错误的,因为地狱让我疯了!有人可以帮助我并解释如何解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

这些是我所知道的组件的最新版本

<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>ecore</artifactId>
    <version>2.3.0-v200706262000</version>
</dependency>
<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>common</artifactId>
    <version>2.3.0-v200706262000</version>
</dependency>
<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>org.eclipse.emf.ecore.xmi</artifactId>
    <version>2.11.0-v20150123-0347</version>
</dependency>

答案 1 :(得分:0)

看看different version in the repository。似乎EMF不久前重命名了他们的文物。而不是这个(类似于你的其他EMF依赖):

<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>ecore</artifactId>
    <version>2.6.1.v20100914-1218</version>
</dependency>

尝试使用此表单(请注意不同的artifactId):

<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>org.eclipse.emf.ecore</artifactId>
    <version>2.11.0-v20150123-0347</version>
</dependency>   

这里有更新版本。对我来说,2.8以上的每个版本似乎都有效。您还可以使用范围,以始终获得最新版本:

<version>[2.8.0,2.99.99]</version>