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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM