我一直在做一个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
^这可能是什么原因呢?
发布于 2019-09-17 07:47:53
Spring不提供该注释。您需要添加javax.inject作为依赖项。我不确定您是如何在不显式添加库的情况下添加该注释的。
https://stackoverflow.com/questions/57965622
复制相似问题