在我的代码中,我遇到了这个常见的错误--“方法不覆盖或实现来自超级类型的方法”。我花了近5个小时阅读过去提供的各种解决方案,但没有一个方案对我有帮助。我错过了什么?
以下是我尝试过的一些事情:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties><plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.8.1</version>
</plugin>
</plugins>我在做什么?
我用的是简单的规则。我实现了RuleListener,如下所示:我一直得到“方法不覆盖或实现超类型的方法”。
public class PositionalStrengthListener implements RuleListener {
private static Logger logger = LoggerFactory.getLogger(PositionalStrengthListener.class);
@Override
public void onSuccess(Rule rule, Facts facts) {
logger.debug("OnSuccess: PositionalStrengthListener");
}
public void onFailure(Rule rule, Facts facts, Exception exception) {
logger.debug("On failure:PositionalStrengthListener");
}
}我关注的是OnSuccess @重写错误消息,因此没有在OnFailure上添加@重写,但如果添加@ OnFailure,则会得到与OnFailure相同的错误。
下面是pom.xml文件中的简单规则依赖项。
<!-- https://mvnrepository.com/artifact/org.jeasy/easy-rules -->
<dependency>
<groupId>org.jeasy</groupId>
<artifactId>easy-rules-core</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.jeasy</groupId>
<artifactId>easy-rules-support</artifactId>
<version>3.3.0</version>
</dependency>发布于 2022-11-23 19:31:19
您回复了Greg-449关于这些导入的评论,但是没有提到您使用什么导入规则。因为jeasy有两个规则类,所以我认为值得再次检查一下。
应该是org.jeasy.rules.api.Rule。我可以通过将导入改为org.jeasy.rules.annotation.Rule来再现编译错误。
另外,请考虑使用easy支持的4.1.0版本,而不是3.3.0。这不是造成这个问题的原因,我只是认为让它们保持同步是个好主意,除非有特定的原因你不能做到。
https://stackoverflow.com/questions/69982093
复制相似问题