【发布时间】:2015-08-27 03:42:05
【问题描述】:
我有一个特点:
trait AbstractSender {
abstract SentTrigger sendMail(Mail main)
SentTrigger sentTrigger(Mail mail){
//do smth here
}
}
我有一堂课:
class EmailSender implements AbstractSender{
@Override
SentTrigger sendMail(Mail mail){
//do some stuff
}
}
我尝试使用 gmavenplus 插件编译它:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<!-- any version of Groovy \>= 1.5.0 should work here -->
<version>2.4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
并获得编译异常:
EmailSender 不是抽象的,不会覆盖 AbstractSender 中的抽象方法 sentTrigger
方法 sentTrigger 已实现。生成的 java 代码是这样的:
@groovy.transform.Trait() public interface AbstractSender
{
;
SentTrigger sendMail(Mail mail);
sentTrigger sentTrigger(Mail mail);
}
这确实解释了编译错误。我用 gmavenplus 插件做错了什么?
【问题讨论】: