Что вызывает «Неудовлетворенная зависимость, выраженная с помощью метода« setTargetDatastore », параметр 0»? - PullRequest
0 голосов
/ 27 декабря 2018

Я новичок в приложениях Spring и пытаюсь интегрировать проект, используя Kotlin + Spring + GORM (который требует использования Groovy).Когда я пытаюсь запустить его, я получаю:

Исключение, обнаруженное при инициализации контекста - отмена попытки обновления: org.springframework.beans.factory.UnsatisfiedDependencyException: Ошибка при создании компонента с именем 'messageController': выражена неудовлетворенная зависимостьчерез метод 'setTargetDatastore' параметр 0;вложенное исключение: org.springframework.beans.factory.BeanCreationException

У меня всего 5 файлов в проекте, включая build.gradle.

Message.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;
}

Message.service

import domain.Message
import groovy.transform.CompileStatic
import org.springframework.stereotype.Service

@CompileStatic
@grails.gorm.services.Service(Message)
@Service
interface MessageService {
    List<Message> findAll()
}

MessageController.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?Есть ли простой прямой способ ее решения?.

Заранее большое спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...