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>即可
scope引起的问题的更多相关文章
- Javascript 的执行环境(execution context)和作用域(scope)及垃圾回收
执行环境有全局执行环境和函数执行环境之分,每次进入一个新执行环境,都会创建一个搜索变量和函数的作用域链.函数的局部环境不仅有权访问函数作用于中的变量,而且可以访问其外部环境,直到全局环境.全局执行环境 ...
- 理解nodejs模块的scope
描述 原文档地址:https://docs.npmjs.com/misc/scope 所有npm模块都有name,有的模块的name还有scope.scope的命名规则和name差不多,同样不能有ur ...
- dagger2系列之Scope
Dagger的Scope注解代表的是作用域,通过实现自定义@Scope注解,标记当前生成对象的使用范围,标识一个类型的注射器只实例化一次,在同一个作用域内,只会生成一个实例, 然后在此作用域内共用一个 ...
- scope.$apply是干嘛的
开始用angular做项目的时候,一定碰到过$scope.$apply()方法,表面上看,这像是一个帮助你进行数据更新的方法,那么,它为何存在,我们又该如何使用它呢. JavaScript执行顺序 J ...
- (转)构建自己的AngularJS,第一部分:Scope和Digest
原翻译链接:https://github.com/xufei/Make-Your-Own-AngularJS/edit/master/01.md 原文链接:http://teropa.info/blo ...
- [Android]使用Dagger 2依赖注入 - 自定义Scope(翻译)
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/5095426.html 使用Dagger 2依赖注入 - 自定义 ...
- AngularJS Scope(作用域)
1. AngularJS Scope(作用域) Scope(作用域) 是应用在 HTML (视图) 和 JavaScript (控制器)之间的纽带. Scope 是一个对象,有可用的方法和属性. Sc ...
- 4种scope方法
默认作用域,自动加载: default_scope { order(created_at: :desc) } model 调用 find_2时才运行 scope :find_2, ->{ whe ...
- angularjs $scope.$watch(),监听值得变化
myApp.controller('firstController',function($scope,$interval){ $scope.date = new Date(); setInterval ...
- angularjs $scope.$apply 方法详解
myApp.controller('firstController',function($scope,$interval){ $scope.date = new Date(); setInterval ...
随机推荐
- jvm003 类加载的过程
类加载的过程 一.加载 在加载阶段虚拟机需要完成以下三件事: 通过一个类的全限定名称来获取此类的二进制字节流 将这个字节流所代表的静态存储结构转化为方法区的运行时数据结构 在内存中生成一个代表这个类的 ...
- 类 java.util.Scannar方法
类 java.util.Scannar方法 ·Scannar (InputStream ln):用给定的输人流创建一个Scanner对象. ·String nextLlne():读取输入的下一行内容. ...
- Unity Shader入门教程(一)
参考文献:http://www.360doc.com/content/13/0923/15/12282510_316492286.shtml Unity Shader是着色器,将纹理.网格信息输入,得 ...
- [补] winpcap编程——EAPSOCKET实现校园网锐捷登录(mentohust)
EAP SOCKET Implement Mentohust 时间20161115 对于EAP协议不了解,可参考上一篇随笔. 通过抓包分析校园网的锐捷登录流程,我在上一篇随笔中实现了EAPSOCKET ...
- 将csv格式的文件数据导入mysql中
示例如下: load data infile 'test.csv'into table `test`fields terminated by ',' optionally enclosed by '& ...
- oracle分组-神奇的cube和rollup
先看代码: 表结构如下: emp表 EMPNO NOT NULL NUMBER(4) ENAME ...
- 关于Class.forName(className).newInstance()介绍
Class.forName(xxx.xx.xx) 返回的是一个类 首先你要明白在java里面任何class都要装载在虚拟机上才能运行.这句话就是装载类用的(和new 不一样,要分清楚). 至于什么时候 ...
- (转)每天一个linux命令(28):tar命令
场景:Linux环境中压缩和解压的命令经常会使用到,所以学好这个命令很有必要! 原文出处:http://www.cnblogs.com/peida/archive/2012/11/30/2795656 ...
- CubieBoard开发板数据源介绍
1: Linaro/Ubuntu Linaro is a not-for-profit engineering organization consolidating and optimizing op ...
- CentOS下安装Nginx服务器
一.nginx安装环境 nginx是C语言开发,建议在linux上运行,本教程使用Centos7作为安装环境. 1.1 gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果 ...