scope引起的问题
背景
执行mvn clean test命令提示部分包不存在,但通过eclipse的clean操作后可以执行mvn test命令
解决方法
mvn clean操作为清空编译的class文件,test的话,会去编译test相关的文件,并执行test
根据日志提示发现,提示不存在的包,都是在pom.xml中加了<scope>test</scope>的
官方解释:
The <scope>
element can take 6 value: compile, provided, runtime, test, system and import.
This scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.
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. provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive. runtime This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath. test This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. system This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository. import (only available in Maven 2.0.9 or later) This scope is only used on a dependency of type pom in the section. It indicates that the specified POM should be replaced with the dependencies in that POM's section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.
加入了<scope>test</scope>的话,包只在编译test部分和执行,而该包在非测试部分也需要引入,所以报错,提示包不存在,所以去掉<scope>即可
- CSS魔法堂:Box-Shadow没那么简单啦:)
- java操作redis: 将string、list、map、自定义的对象保存到redis中
- 运行第一个Docker容器-Docker for Web Developers(1)
- 手动实现jQuery Tools里面tab功能
- Angular企业级开发(9)-前后端分离之后添加验证码
- 基于thrift的微服务框架
- Sublime Text 快速格式化
- HTML中拖放介绍
- 打造高效前端工作环境 - tmux
- 基于thrift的微服务框架
- thrift中的超时(timeout)坑
- 基于webmagic的爬虫项目经验小结
- Docker Hub工作流程-Docker for Web Developers(6)
- PHP+MySQL代码部署在Linux(Ubuntu)上注意事项
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Android ImageView 固定宽高比例的实现方法
- Android 实现IOS选择拍照相册底部弹出的实例
- ubuntu 20.04上搭建LNMP环境的方法步骤
- Android实现界面内嵌多种卡片视图(ViewPager、RadioGroup)
- Android设计模式之Builder模式详解
- 详解Android获取系统内核版本的方法与实现代码
- Android 修改viewpage滑动速度的实现代码
- 在Ubuntu20.04中安装ROS Noetic的方法
- Android设计模式之单例模式详解
- Android获取手机联系人的方法
- 学习使用Material Design控件(一)
- Android仿微信Viewpager-Fragment惰性加载(lazy-loading)
- Android嵌套滑动冲突的解决方法
- Android应用图标上的小红点Badge实践代码
- 详解Android studio中正确引入so文件的方法