我有一个特点:
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插件做错了什么?
答案 0 :(得分:0)
这不是GMavenPlus配置问题。您可以将它放在GroovyConsole中以演示此
ColorImages
您看到的错误消息是正确的。 Uncaught TypeError: FinalPrice.toFixed is not a function
GetPriceForChildren @ purchase-product:642
$.each.$.click.$.ajax.success @ purchase-product:693
n.Callbacks.j @ jquery-1.11.0.min.js:2
n.Callbacks.k.fireWith @ jquery-1.11.0.min.js:2
x @ jquery-1.11.0.min.js:4
n.ajaxTransport.send.b @ jquery-1.11.0.min.js:4
仅实施trait AbstractSender {
abstract SentTrigger send(Mail main)
SentTrigger sentTrigger(Mail mail) { }
}
class EmailSender implements AbstractSender{
@Override
SentTrigger sendMail(Mail mail) { }
}
class Mail { }
class SentTrigger { }
new EmailSender()
,而不是EmailSender
。如果您将sendMail()
重命名为send()
,则应该正确编译。