问题:

spring引入@Aspect注解始终爆红,无法引入:

排查:

步骤1:

查看依赖包:

经过查看已经导入,没有问题

步骤2:

发现导入的依赖多了一个<scope>runtime</scope>这个:

<scope>runtime</scope>

意思:runtime 是运行的意思。指的是直接在运行时所需要的包,而非在编译时等时候需要的包

步骤3:

去掉<scope>runtime</scope>

问题解决

思考:

  1. <scope>官方文档解释

英文原文摘录出来如下:

The scope of the dependency - compile, runtime, test, system, and provided. Used to calculate the various classpaths used for compilation, testing, and so on. It also assists in determining which artifacts to include in a distribution of this project. For more information, see the dependency mechanism. The default scope is compile.

默认是编译的

compile,runtime看下官网原文解释:

  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. Maven includes a dependency with this scope in the runtime and test classpaths, but not the compile classpath.

这个就清晰了,runtime这个是在运行及测试路径中使用的

  1. 官方依赖为啥会直接添加<scope>runtime</scope>呢?

这个真是个大坑呀,只不过不太明白官方为啥添加这个

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐