0

I am new to gradle and I am building a project in it.Now I want to import a maven dependency from local repo into my gradle project .So the path to my local repo is like

Users/test/.m2/org/springframework/spring-jdbc/4.3.8.RELEASE

So what I have tried is

maven{
       url uri('/Users/test/.m2/repository')
       }
    repositories {
      mavenLocal()
      mavenCentral()


    }

and

My build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.smudmmlta.dgs'
version = '1.0'
sourceCompatibility = 1.8
maven{
url uri('/Users/test/.m2/repository')
}
repositories {
    mavenCentral()
    mavenLocal()
}
dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile('org.springframework.dao')
    compile('com.zaxxer:HikariCP:2.7.6')
    compile('org.mindrot:jbcrypt:0.4')
    compile('org.springframework:spring-jdbc')   
}

After this still the program throws error as below:

import org.springframework.jdbc.core.JdbcTemplate;

The import org.springframework.jdbc cannot be resolved

because of unresolved dependencies. Any help is appreciated.

EDIT I also changed this part to be like

 repositories {
      mavenLocal()
      mavenCentral()
      maven{
       url uri('/Users/test/.m2/repository')
       }

    }
Ricky
  • 2,662
  • 5
  • 25
  • 57
  • `4.8.3` is hardly `4.3.8`... Also you should be using the `spring-boot-starter-jdbc` instead of manually wanting to add the `spring-jdbc` dependency so that you get the correct version. Also if you really want to use `spring-jdbc` as a dependency as you do now do it **without** the version number. Spring Boot will manage the version for you. (And just use `mavenLocal()` as the repo). – M. Deinum Jan 25 '18 at 07:18
  • Is it possible to show the build.gradle file required since I am not getting exactly what are you are saying by Spring Boot will manage the version for you.Thanks – Ricky Jan 25 '18 at 07:24
  • Just remove the version number from the dependency and use `spring-boot-starter-jdbc` instead of `spring-jdbc`. – M. Deinum Jan 25 '18 at 07:25
  • Tried s above but still error is not gone\ – Ricky Jan 25 '18 at 07:26
  • When adking about an error, **post the error**. – JB Nizet Jan 25 '18 at 07:26
  • @JB Nizet Updated the question – Ricky Jan 25 '18 at 07:28
  • The program doesn't throw an error. This is a compilation error. How do you get it? What are you doing to get this error? – JB Nizet Jan 25 '18 at 07:32
  • After adding the dependency `compile('org.springframework:spring-jdbc')` and `maven{ url uri('/Users/test/.m2/repository') } repositories { mavenCentral() mavenLocal() }` this error shoul get resolved right.But it does not. – Ricky Jan 25 '18 at 07:32
  • You don't need to add `mavenLocal()`, and even less `maven url ...`. All these dependencies are in maven central. And you didn't answer my question. – JB Nizet Jan 25 '18 at 07:36
  • I am not doing any thing to get this error.when I use the class inside the import library it does not identifies – Ricky Jan 25 '18 at 07:38
  • Where is this error appearing? In your console? As a response to which command? In your IDE? Which IDE? As a response to which action? Java compilation errors don't appear in front of me when I just look at the blue sky. I need to do something to get them. I bet it's the same for you. – JB Nizet Jan 25 '18 at 07:56
  • In my IDE STS .the issue is it doesn't identify the jdbc library .So it could not import the classes from it hence the dependency is unresolved. – Ricky Jan 25 '18 at 08:11
  • https://stackoverflow.com/questions/17907927/update-my-gradle-dependencies-in-eclipse – JB Nizet Jan 25 '18 at 10:50

0 Answers0