Unable to build gradle project

Viewed 58

I am not able to build my gradle project. I have installed gradle in my saystem and building it through command promt. , getting this below error. enter image description here

Error : Could not resolve all files for configuration ':compileClasspath'.

My build.gradle is :

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

apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

repositories {
    maven { url 'https://repo.spring.io/libs-snapshot' }
}

dependencies {
   compile('org.springframework.cloud:spring-cloud-starter-eureka-server')
   testCompile('org.springframework.boot:spring-boot-starter-test')
   compile('org.springframework.boot:spring-boot-starter-actuator')
}

mainClassName = 'server.Main'

allprojects {
  apply plugin: 'java'
  apply plugin: 'eclipse'
  
  dependencies {
    compile 'log4j:log4j:1.2.17'
    testCompile 'junit:junit:4.12'
        
  }
  sourceCompatibility = '1.8'
  targetCompatibility = '1.8'
  
  dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Camden.SR5'
    }
  }
  
    task deletelogs(type: Delete) {
      delete 'logs', 'bin', '.settings', '.classpath', '.project'
      followSymlinks = true
     
    }
    
    task deleteBin(type: Delete) { 
        delete 'bin'
        followSymlinks = true;
    }
    
    task deleteBuild(type: Delete) { 
        delete 'build'
        followSymlinks = true;
    }
    
    task deleteLogs(type: Delete){ 
        delete 'logs'
        followSymlinks = true;
    }
}

Can anyone let me know what can be the issue? Please help!

2 Answers

Looks like gradle cannot connect to that repository or cannot find log4j in that repository.

You can try adding another repository to download log4j (or any other dependencies) from.

Add mavenCentral() in the second repositories block, so that it becomes:

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/libs-snapshot' }
}

Else it will look for all your libs in the spring snapshots, which won't work.

Related