nope
nope

Reputation: 151

Why can't my project locate org.springframework.test or org.springframework.boot.test?

Problem:

Error:(15, 10) java: cannot find symbol
  symbol: class SpringRunner
Error:(16, 2) java: cannot find symbol
  symbol: class SpringBootTest
Error:(12, 47) java: package org.springframework.test.context.junit4 does not exist
Error:(10, 47) java: package org.springframework.test.context.junit4 does not exist
/home/ian/Development/JavaEE/RestCalculator/src/main/java/com/testApp/calculator/ApplicationTest.java
Error:(11, 45) java: package org.springframework.boot.test.context does not exist

Background

I am trying to write a Unit test for a simple spring application. The application is built using Gradle. The following code is my build.gradle.

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

jar {
    baseName = 'calculator'
    version =  '0.1.0'
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
    }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    compile("org.springframework.kafka:spring-kafka:1.3.2.RELEASE")
    testCompile('junit:junit:4.12')
    compile('junit:junit:4.12')
}

Attached is an image showing showing all the libraries associated with this project, which I believe includes the necessary test libraries.

enter image description here

Question

Why can't my project locate org.springframework.test or org.springframework.boot.test?

Attempts at solution

I figure I must be missing something in my build.gradle, but I am at my wits end as to what it is. Any help is appreciated. Thanks.

Upvotes: 0

Views: 2436

Answers (1)

elmehdi
elmehdi

Reputation: 479

I have copy your gradle config, and everything seems working as expected, to avoid any issue about starting new project you can download this example from spring guide and then customize dependencies as you like

Upvotes: 1

Related Questions