spark.sql.SqlContext等包找不到

博客讲述了在遇到`spark.sql.SqlContext`等包找不到的问题时,如何通过修改pom文件注释掉依赖包范围并重新导入依赖来解决问题。同时,提到了maven依赖范围的简单说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

##spark.sql.SqlContext等包找不到##

报错信息如下:

百度了很多,没有找到原因,后在一朋友指导下修复了该问题

解决方案

修改pom,

把依赖包的范围给注释掉

然后reimport dependencies

重新运行main示例,问题解决

关于maven依赖范围的几点补充:

scope:
This element refers to the classpath of the task at hand (compiling and runtime, testing, etc.) as well as how to limit the transitivity of a dependency. There are five scopes available:

compile - this is the default scope, used if none is specified. Compile dependencies are available in all classpaths. 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 it at runtime. It 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. It is not transitive.

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.

简而言之:

compile:编译/运行/测试,打包的时候包含,默认的依赖
provided:编译/运行/测试,打包的时候不包含
runtime:运行时
system:与provided类似,不过是从本地导入
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值