@DisabledInAotMode

@DisabledInAotMode 表示带注释的测试类已在 Spring AOT(提前)模式中禁用,这意味着该测试类的 ApplicationContext 不会在构建时处理 AOT 优化。

@DisabledInAotMode signals that the annotated test class is disabled in Spring AOT (ahead-of-time) mode, which means that the ApplicationContext for the test class will not be processed for AOT optimizations at build time.

如果使用 @DisabledInAotMode 对测试类进行了注释,则所有指定配置加载相同 ApplicationContext 的其他测试类也必须注释为 @DisabledInAotMode。未能注释所有此类测试类将导致异常,无论是在构建时还是在运行时。

If a test class is annotated with @DisabledInAotMode, all other test classes which specify configuration to load the same ApplicationContext must also be annotated with @DisabledInAotMode. Failure to annotate all such test classes will result in an exception, either at build time or run time.

当与基于 JUnit Jupiter 的测试一起使用时,@DisabledInAotMode 还表示在以 Spring AOT 模式运行测试套件时禁用了带注释的测试类或测试方法。当在类级别应用时,该类中的所有测试方法都将被禁用。从这个意义上说,@DisabledInAotMode 具有与 JUnit Jupiter 的 @DisabledInNativeImage 注解相似的语义。

When used with JUnit Jupiter based tests, @DisabledInAotMode also signals that the annotated test class or test method is disabled when running the test suite in Spring AOT mode. When applied at the class level, all test methods within that class will be disabled. In this sense, @DisabledInAotMode has semantics similar to those of JUnit Jupiter’s @DisabledInNativeImage annotation.

有关针对集成测试的 AOT 支持的详细信息,请参见Ahead of Time Support for Tests

For details on AOT support specific to integration tests, see Ahead of Time Support for Tests.