Java SpringBoot中使用sqljdbc4注意事项 java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

因项目需要,需要在Java项目中访问 MSSQLServer 数据库,本地开发的时候,没有问题,可以正常链接数据库,通过Jenkins部署到服务器上时候,报数据库驱动未找到。

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

原因:pom.xml 的包未找到:


<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
</dependency>

解决方法:需要手工在服务器上安装一下 sqljdbc:

mvn install:install-file -Dmaven.repo.local=/newdata/jenkins/maven-repositories/0 -Dfile=sqljdbc4-4.0.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar

原文地址:https://www.cnblogs.com/jimcsharp/p/9796123.html