【问题标题】:Gradle Could not resolve: com.microsoft.sqlserver:sqljdbc4:4.0Gradle 无法解析:com.microsoft.sqlserver:sqljdbc4:4.0
【发布时间】:2017-07-25 20:56:06
【问题描述】:

请帮我解决这个错误...

build.gradle中添加了依赖

**// https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4
testCompile group: 'com.microsoft.sqlserver', name: 'sqljdbc4', version: '4.0'**

Refresh Gradle Project 后,出现如下错误:

**Could not resolve: com.microsoft.sqlserver:sqljdbc4:4.0**

【问题讨论】:

    标签: sql-server gradle build.gradle gradle-eclipse


    【解决方案1】:

    “在本地添加后它对我有用,这是我在 Eclipse Neon 中的步骤。”

    Step 1.
    create 'lib' folder under main project
    
    
    Step 2.
    copy the jar file 'sqljdbc4' to lib folder
    
    
    Step 3.
    Add below dependency in 'build.gradle' file
    repositories {
        jcenter()
        mavenCentral()
        flatDir {
            dirs 'lib'
        }
    }
    
    
    
    dependencies {
     compile name: "sqljdbc4-4.0"
    }
    
    
    
    Step 4.
    Right click on main Project and refresh gradle
    

    【讨论】:

    • 在 7.1.1 版本的 gradle 中添加平面目录也对我有用,没有从命令提示符尝试任何 IDE
    【解决方案2】:

    我不确定你的 build.gradle 文件。

    它应该工作。

    testCompile 组:'com.microsoft.sqlserver',名称:'sqljdbc4', 版本:'4.0'`

    在 maven 存储库中可用。

    你给了吗

    repositories {
            mavenCentral();
    }
    

    作为 build.gradle 文件中的存储库?如果你给了这个,那么它应该可以工作。

    如果它不起作用,请在此处分享您的完整 build.gradle 文件和错误跟踪,以便我们对您的问题有更多了解

    【讨论】:

      【解决方案3】:

      要正确解决依赖关系,您需要添加 jar 所在的 maven url。

      在存储库下添加:

          maven { url "http://repo.spring.io/plugins-release/" }
      

      应该看起来像这样(这声明了多个存储库):

          repositories {
              mavenCentral()
              maven { url "https://repo.spring.io/milestone" }
              maven { url "http://repo.spring.io/plugins-release/" }
          }
      

      【讨论】:

        猜你喜欢
        • 2013-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-30
        • 2018-04-08
        • 1970-01-01
        • 1970-01-01
        • 2022-10-31
        相关资源
        最近更新 更多