QA-IDEA中用maven配置项目无法加载JDBC
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Im building Maven Java Web application and when I do
Class.forName("com.mysql.jdbc.Driver");
I get
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
mysql-connector
is added to my pom.xml
file like this
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
<scope>provided</scope>
</dependency>
But I keep getting this. I even tried downloading mysql-connector
and adding it manually to project, but it doesn't change anything.
I also have the same app without Maven, and same code works fine
Answer:
You have set the scope of your dependency as provided
. This means that the jar is used when compiling the project (although you shouldn't need it to compile it, since you should only use standard JDBC classes), but that it's not included in the jar or war created by the build, because this dependency is supposed to be "provided" by the application server where you deploy the application.
So, either you actually intend to have this jar provided, and it should be in the application server's classpath, or you want to bundle this jar with the application, and it should have the scope runtime
(because you need it to run the app, but not to compile it), instead of provided
.
QA-IDEA中用maven配置项目无法加载JDBC的更多相关文章
- Maven配置本地库加载ojdbc14-10.2.0.4.0.jar文件
因为ojdbc14-10.2.0.4.0.jar是要收费的,所以Maven的远程库里没有这个资源,只能通过配置本地库来加载到J2EE工程里,做法如下: 第一步:在网上下载ojdbc14.jar,然 ...
- Maven配置项目依赖使用本地仓库的方法汇总
Maven配置项目使用本地仓库有以下方式实现: 1.类似本地仓库,但是属于本地依赖,比如某个JAR包是引用第三方的,直接放在了项目的lib文件夹,那么此时可以如下配置项目的POM: <depen ...
- Springboot项目自动加载设置
SpringBoot是允许项目自动加载的,但是需要在pom文件映入依赖库 1.导入依赖库 <dependency> <groupId>org.springframework.b ...
- Smart3D系列教程7之 《手动配置S3C索引加载全部的瓦片数据》
一.前言 迄今为止,Wish3D已经出品推出了6篇系列教程,从倾斜摄影的原理方法.采集照片的技巧.Smart3D各模块的功能应用.小物件的照片重建.大区域的地形重建到DSM及正射影像的处理生产,立足于 ...
- quartz.net 项目无法加载的问题
最近尝试试用一下quartz.net 做任务调度用. 下载了源代码后打开解决方案发现项目无法加载.错误如下 未找到导入的项目“C:\Users\****\Desktop\Quartz.NET-2.1. ...
- 无法加载ISAPI 筛选器 当前配置只支持加载为 AMD64 处理器体系结构创建的映像
无法加载ISAPI 筛选器 当前配置只支持加载为 AMD64 处理器体系结构创建的映像 2011-11-9 0:18:49来源:本站原创作者:清晨320我要评论(0) 今天服务器的伪静态死活加载不上去 ...
- 007-spring cloud gateway-GatewayAutoConfiguration核心配置-RouteDefinition初始化加载
一.RouteDefinitionLocator 在Spring-Cloud-Gateway的GatewayAutoConfiguration初始化加载中会加载RouteDefinitionLocat ...
- vue-loader 调用了cssLoaders方法配置了css加载器属性。
module: { loaders: [ // 这里也是相应的配置,test就是匹配文件,loader是加载器, { test: /\.vue$/, loader: 'vue' }, { test: ...
- DB数据源之SpringBoot+MyBatis踏坑过程(二)手工配置数据源与加载Mapper.xml扫描
DB数据源之SpringBoot+MyBatis踏坑过程(二)手工配置数据源与加载Mapper.xml扫描 liuyuhang原创,未经允许进制转载 吐槽之后应该有所改了,该方式可以作为一种过渡方式 ...
随机推荐
- Bugfree安装与使用
第一步:下载XAMPP和bugfree http://www.bugfree.org.cn/ http://www.apachefriends.org/zh_cn/xampp.html 第二步:安装 ...
- 说说移动端web开发中的点击穿透问题
最近一直在忙于一个无线端的项目,由于之前主要工作都是在桌面端,移动端接触的比较少,所以中间遇到了很多的坑,做一个简单的记录. 问题背景 需求中有这样的一个功能,点击取件信息的时候会弹出一个地址列表的浮 ...
- eclipse中修改tomcat的配置,解决全局性的get提交乱码问题
在项目中如果页面提交方式为get的时候,中文会出现乱码. 为了解决乱码问题我们有两种办法. 第一种:在程序中加入get提交乱码的解决 String username = new String(user ...
- CentOS6.4 安装sftp
1.打开命令终端窗口,按以下步骤操作.使用ssh -V 命令来查看openssh的版本,版本必须大于4.8p1,低于的这个版本需要升级. [root@ecs-3c46 ~]# ssh -v OpenS ...
- orcale 之函数
我们知道存储过程的调用是一条 PL/SQL 语句.那么对于一些表达式我们用什么呢?这里函数的功能就会体现出来了. 函数和过程在创建方式上有很多的类似地方,也是编译后放入内存中以供用户使用,只不过函数调 ...
- AOP的最佳注入方式——MSIL注入
下载PostSharp(Visual Studio Gallery). 安装一个AOP编译器和引入PostSharp.Aspects(注意安装过程中请使用免费的Express版本),然后初步演示代码: ...
- Python基础(8) - 模块
Python 模块的物理形式就是文件:一个文件对应一个模块.文件名就是模块名+.py 模块定义了自己独有的命名空间.在其定义的属性,函数,类都隶属于该空间. 通过import关键字我们可以导入模块: ...
- hihocoder #1529 : 不上升序列
Description 给定一个长度为 n 的非负整数序列 a[1..n]. 你每次可以花费 1 的代价给某个 a[i] 加1或者减1. 求最少需要多少代价能将这个序列变成一个不上升序列. Solut ...
- 将forme表单转换为Json对象
//将Form 表单转换为Json字符串 $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); ...
- VMWARE 12安装Tools
准备条件 1.yum install perl 2.yum install gcc 接着就是挂载安装 新建cdrom挂载目录mkdir /mnt/cdrom挂载光驱mount -t auto /dev ...