You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Allure2的@Step注解时出现NoSuchMethodError错误求助

Troubleshooting the Allure @Step NoSuchMethodError Issue

Hey there, let's work through this frustrating Allure @Step error together. That NoSuchMethodError for StepsAspects.aspectOf() almost always ties back to dependency conflicts or issues with AspectJ weaving not working correctly. Here are actionable steps to fix it:

  • Verify AspectJ Version Compatibility
    Allure 2.6.0 might have compatibility issues with older AspectJ versions like 1.9.1. Try upgrading your aspectj.version to a newer release (e.g., 1.9.7 or later). Update the property in your pom.xml and re-run the tests—this often resolves method mismatch issues between Allure's aspects and the weaver.

  • Fix Surefire Plugin's ArgLine Configuration
    Double-check the argLine in your Maven Surefire plugin. Sometimes the path to the aspectjweaver jar isn't resolving correctly. You can try a more reliable way to reference the weaver:

    <argLine>
      -javaagent:"${maven.dependency.org.aspectj.aspectjweaver.jar.path}"
    </argLine>
    

    Also, ensure there are no extra spaces or typos in the path, and that the aspectjweaver dependency is correctly declared in the Surefire plugin's dependencies section.

  • Scan for Dependency Conflicts
    Run mvn dependency:tree in your project root to check for conflicting versions of Allure or AspectJ dependencies. Look for any transitive dependencies pulling in older versions of allure-aspects or aspectjrt—exclude those conflicting versions explicitly in your pom.xml. For example:

    <dependency>
      <groupId>problematic-group</groupId>
      <artifactId>problematic-artifact</artifactId>
      <exclusions>
        <exclusion>
          <groupId>io.qameta.allure</groupId>
          <artifactId>allure-aspects</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
  • Clean and Refresh Maven Dependencies
    Corrupted or incomplete dependencies in your local Maven cache can cause weird class/method not found errors. Delete the io/qameta/allure and org/aspectj folders from your local repository (usually located at ~/.m2/repository), then run mvn clean install -U to re-download fresh copies of all dependencies.

  • Check @Step Annotation Usage
    Make sure your @Step annotations are applied to public methods—Allure's AspectJ weaving won't pick up annotations on private or package-private methods. Also, avoid using @Step on static methods unless you've configured AspectJ to handle static weaving (which requires extra setup).

  • Compare with Your Working Project
    Since you have another project with the same Allure version that works, run mvn dependency:tree on both projects and compare the outputs. Look for any differences in dependency versions, excluded artifacts, or plugin configurations—even a small discrepancy could be the root cause.

  • Simplify and Update Plugin Configurations
    You're right that you don't need both the allure-maven dependency and plugin. Stick with the plugin only, and try upgrading the allure-maven plugin version to a newer release (e.g., 2.12.0) that's compatible with Allure 2.6.0. Sometimes outdated plugins can cause weaving issues.

内容的提问来源于stack exchange,提问作者Laucien

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:49:47