0

我一直在从事 Spring Boot 项目(版本 2.0.4.RELEASE)。以下是 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()
}

我通过在 Gradle 中使用 eclipse 插件创建 eclipse 配置文件将项目导入到 eclipse 中。

我使用javax.inject.Inject注释而无需添加额外的依赖项,并使用 eclipse 运行应用程序而没有任何问题。

但是,当我最近在命令行上进行了干净的构建时,构建失败了,因为它找不到@Inject

error: cannot find symbol
        @Inject
         ^

这可能是什么原因?

4

1 回答 1

0

Spring 不提供该注释。您需要添加 javax.inject 作为依赖项。我不确定您如何在不显式添加该库的情况下添加该注释。

于 2019-09-16T23:47:52.540 回答