spring - 是什么导致“通过方法'setTargetDatastore'参数0表达的不满足的依赖关系”?
问题描述
我是 Spring 应用程序的新手,我正在尝试使用 Kotlin + Spring + GORM 集成一个项目(这需要使用 Groovy)。当我尝试运行它时,我得到:
上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“messageController”的bean时出错:通过方法“setTargetDatastore”参数0表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException
我在项目中只有 5 个文件,包括 build.gradle。
消息.groovy
import grails.gorm.annotation.Entity
import groovy.transform.ToString
import org.grails.datastore.gorm.GormEntity
@ToString
@Entity
class Message implements GormEntity<Message> {
String user;
String date;
String message;
}
消息服务
import domain.Message
import groovy.transform.CompileStatic
import org.springframework.stereotype.Service
@CompileStatic
@grails.gorm.services.Service(Message)
@Service
interface MessageService {
List<Message> findAll()
}
消息控制器.groovy
@RestController
@Transactional
class MessageController {
@Autowired
MessageService messageService
@RequestMapping("/")
List<String> index() {
return messageService.findAll().collect { "[" + it.user + "@" + it.date + ": " + it.message + "]" }
}
@RequestMapping(value = "/save/", method = RequestMethod.POST)
String save(@RequestBody Message message) {
message.save()
return "Saved"
}
}
应用程序.kt
@SpringBootApplication
class SimManagerApplication
fun main(args: Array<String>) {
SpringApplication.run(SimManagerApplication::class.java, *args)
}
build.gradle 依赖项
dependencies {
compile('org.springframework.boot:spring-boot-starter-quartz')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.fasterxml.jackson.module:jackson-module-kotlin')
compile('com.vaadin:vaadin-spring-boot-starter')
compile('org.flywaydb:flyway-core')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlin:kotlin-reflect")
compile("com.h2database:h2")
compile("eu.vaadinonkotlin:vok-rest:0.6.2")
compile('org.codehaus.groovy:groovy-all:2.5.4')
compile("org.flywaydb:flyway-core:5.2.0")
compile "org.grails:gorm-hibernate5-spring-boot:6.1.6.RELEASE"
compile "org.hibernate:hibernate-core:5.1.0.Final"
compile "org.hibernate:hibernate-ehcache:5.1.0.Final"
runtime "org.apache.tomcat:tomcat-jdbc:8.5.0"
runtime "org.apache.tomcat.embed:tomcat-embed-logging-log4j:8.5.0"
runtime "org.slf4j:slf4j-api:1.7.10"
}
就这么简单,项目无法启动。究竟是什么导致了 UnsatisfiedDependencyException?有没有简单直接的方法来解决它?
非常感谢您提前。
解决方案
推荐阅读
- angular - Angular:获取请求处理 ByteBuffer 的通量
- python - 编写正则表达式以从另一个任意字符串中查找模式
- java - 在 Java TeraSoluna 框架中重复一个 Job Tasklet
- javascript - 数据正在正确获取,但为什么不显示?
- ffmpeg - 用于创建单个 .m4s 片段的 Java mp4parser — 无效的 moov 框
- javascript - 如何计算javascript中字符串的每个连续唯一字符的数量
- vue.js - 检查事件时的问题是公共假期然后在全日历中更改其容器(td 单元格)的背景?
- node.js - 错误:连接 ECONNREFUSED 142.251.10.108:465 Nodemailer ejs 渲染 | 本地主机
- android - @SerializedName val 无法在构造函数中初始化
- algorithm - 这个算法的复杂度是多少?