0

I have been working on a Spring Boot project (version 2.0.4.RELEASE). Following is the build.gradle


plugins {

    id 'java'
    id 'eclipse'

    id 'org.springframework.boot' version '2.0.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

sourceCompatibility = 1.8

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    runtimeOnly 'com.h2database:h2'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

repositories {
    jcenter()
}

I imported the project to eclipse by creating the eclipse config files using eclipse plugin in Gradle.

I used javax.inject.Inject annotation without having to add an additional dependency, and ran the application using eclipse without any issues.

However, when I did a clean build on command line recently, the build failed because it could not find @Inject

error: cannot find symbol
        @Inject
         ^

What could be the cause of this?

Dilini Rajapaksha
  • 2,610
  • 4
  • 30
  • 41

1 Answers1

0

Spring does not provide that annotation. You need to add javax.inject as a dependency. I'm not sure how you were able to add that annotation without explicitly adding that library.

mre
  • 43,520
  • 33
  • 120
  • 170