我正在尝试使用Microsoft sql服务器连接构建springboot应用程序。我建立了与mysql的连接,并且工作正常,但是现在我无法连接到mssql数据库,因为springboot gradle脚本不会加载'com.microsoft.sqlserver:sqljdbc4' jar。我试图通过gradle脚本在非springboot项目中加载jar,它工作正常。 springboot正在做我不知道的事情吗?还是还有其他问题?

我的gradle脚本:

buildscript {
    ext {
        springBootVersion = '1.4.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'BEAT-Surflet'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('com.microsoft.sqlserver:sqljdbc4')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework:spring-jms')
    compile('org.apache.activemq:activemq-broker')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

也许问题是,springboot试图自己加载版本或由于版本冲突。我也尝试过给他这个版本('com.microsoft.sqlserver:sqljdbc4:4.0'),但是它也不起作用。那么,为什么我的gradle-script或springboot项目没有加载mssql jar?

最佳答案

我有类似的问题。我通过使用net.sourceforge.jtds 1.3.1解决了这个问题。司机。我建议将此驱动程序用于MSSQL数据库。
Microsoft驱动程序确实存在错误,并且不支持某些广泛使用的数据类型。

10-08 01:55