Spring boot Spring Boot JPA是一个正交集还是缺少依赖性
我试图使用JpaRepository接口方法,但它会导致该错误 服务Spring boot Spring Boot JPA是一个正交集还是缺少依赖性,spring-boot,spring-data-jpa,Spring Boot,Spring Data Jpa,我试图使用JpaRepository接口方法,但它会导致该错误 服务 @Service class PatientService { @Autowired lateinit var repository: PatientRepository fun findAllPatients() : List<PatientDto> { val patients: List<Patient> = repository.findAll()
@Service
class PatientService {
@Autowired
lateinit var repository: PatientRepository
fun findAllPatients() : List<PatientDto> {
val patients: List<Patient> = repository.findAll()
return arrayListOf() //Ignore this return!
}
}
应用程序
@Configuration
@EnableTransactionManagement
@EnableAspectJAutoProxy
@EnableJpaRepositories("br.com.zetait.odontofy.repository")
@EntityScan("br.com.zetait.odontofy.entity")
class RepositoryConfig
@SpringBootApplication(scanBasePackages = [
"br.com.zetait.odontofy.controller",
"br.com.zetait.odontofy.service",
"br.com.zetait.odontofy.repository"
])
class OdontofyApplication
fun main(args: Array<String>) {
runApplication<OdontofyApplication>(*args)
}
@SpringBootApplication(scanBasePackages = [
"br.com.zetait.odontofy.controller",
"br.com.zetait.odontofy.service",
"br.com.zetait.odontofy.repository"
])
class OdontofyApplication
fun main(args: Array<String>) {
runApplication<OdontofyApplication>(*args)
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.data:spring-data-commons")
implementation("org.postgresql:postgresql")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
runtimeOnly("com.h2database:h2")
runtimeOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}