问题:
spring引入@Aspect注解始终爆红,无法引入:
![](https://img-blog.csdnimg.cn/img_convert/84edb0218bb1fe0aca3a4c8e3e8a8710.png)
排查:
步骤1:
查看依赖包:
经过查看已经导入,没有问题
![](https://img-blog.csdnimg.cn/img_convert/f8a701bd1b7043dc2d1b2914c53440ec.png)
![](https://img-blog.csdnimg.cn/img_convert/07d809081f86d403c34dbb49c0b2b712.png)
步骤2:
发现导入的依赖多了一个<scope>runtime</scope>这个:
<scope>runtime</scope>
意思:runtime 是运行的意思。指的是直接在运行时所需要的包,而非在编译时等时候需要的包
步骤3:
去掉<scope>runtime</scope>
问题解决
思考:
-
<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
.
![](https://img-blog.csdnimg.cn/img_convert/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这个是在运行及测试路径中使用的
-
官方依赖为啥会直接添加<scope>runtime</scope>呢?
这个真是个大坑呀,只不过不太明白官方为啥添加这个