【解决问题】spring@Aspect注解无法引入

本是古典 何须时尚 2023-10-09 15:31 96阅读 0赞

问题:

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

84edb0218bb1fe0aca3a4c8e3e8a8710.png

排查:

步骤1:

查看依赖包:

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

f8a701bd1b7043dc2d1b2914c53440ec.png

07d809081f86d403c34dbb49c0b2b712.png

步骤2:

发现导入的依赖多了一个runtime这个:

runtime

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

步骤3:

去掉runtime

问题解决

思考:

  1. 官方文档解释

英文原文摘录出来如下:

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.

c5183166b2d2bb77c0aa365e6f84fd70.png

默认是编译的

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. 官方依赖为啥会直接添加runtime呢?

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

发表评论

表情:
评论列表 (有 0 条评论,96人围观)

还没有评论,来说两句吧...

相关阅读