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>即可
- 1.如何在CentOS6.5安装OpenLDAP并配置客户端
- PHP 面试知识梳理
- 如何修改CM及CDH元数据库配置
- 如何实现CDH元数据库MySQL的高可用
- 如何实现CDH元数据库MySQL的主主互备
- 在Kerberos环境使用Hue通过Oozie执行Sqoop作业报错异常分析
- 如何在Hue中配置已启用SSL的HttpFS服务
- 如何使用Nginx实现CDSW的跨网段访问
- 7.如何在OpenLDAP中实现将一个用户添加到多个组
- 如何使用java代码通过JDBC访问Sentry环境下的Hive
- 如何为HttpFS服务配置SSL
- 如何使用Java访问集成OpenLDAP并启用Sentry的Impala和Hive
- 如何向Hive表加载数据
- 如何使用Spark Streaming读取HBase的数据并写入到HDFS
- 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 数组属性和方法
- Django开发的简易留言板案例详解
- php使用redis的有序集合zset实现延迟队列应用示例
- PHP使用openssl扩展实现加解密方法示例
- php使用redis的几种常见操作方式和用法示例
- 使用memory_profiler监测python代码运行时内存消耗方法
- php 多进程编程父进程的阻塞与非阻塞实例分析
- php数组指针函数功能及用法示例
- thinkphp5框架路由原理与用法详解
- ThinkPHP5&5.1实现验证码的生成、使用及点击刷新功能示例
- php反序列化长度变化尾部字符串逃逸(0CTF-2016-piapiapia)
- 对python 命令的-u参数详解
- ThinkPHP5.1+Ajax实现的无刷新分页功能示例
- Python推导式简单示例【列表推导式、字典推导式与集合推导式】
- Python 从相对路径下import的方法
- Python随机生成身份证号码及校验功能