在我的一些maven模块(例如myChild)中,我使用maven-jar-plugin创建了一些额外的jar,在这里命名为my-plugin.jar。这个my-plugin.jar应该只是整个模块的一部分 - myChild.jar。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=...>
<modelVersion>4.0.0</modelVersion>
<artifactId>myChild</artifactId>
<parent>
<groupId>org.group</groupId>
<artifactId>myParent</artifactId>
<version>1.0</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>build-plugins-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<includes>
<include>......</include>
</includes>
<finalName>my-plugin</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
...........
</dependencies>
当我想在另一个maven模块中使用myChild模块时(例如myExternal),我添加了对myChild的依赖。但myExternal的编译由于以下错误而失败:method does not override or implement a method from a supertype
。当我删除两个@Override注释时,错误数量减少了两个。似乎使用了Java 1.4。但是父POM的maven-compiler-plugin包含source
和target
1.7。
更令人好奇的是,myChild模块编译得很好。但是当使用myChild的其他模块正在编译时,会出现上述错误。
答案 0 :(得分:0)
好的,根据published code,您需要将maven-compiler-plugin
配置从plugins
移至pluginsManagement
部分,以便在所有子模块中都可见。
<pluginManagement>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</pluginManagement>