首页 > 解决方案 > 在尝试使用“spring-boot-starter-websocket”插件之前,有人遇到过这个错误吗?

问题描述

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is org.grails.core.exceptions.GrailsRuntimeException: Error instantiated artefact class [class abc.MessageController] of type [class org.grails.core.DefaultGrailsControllerClass]: InvocationTargetException

下面是我在 build.gradle 中的代码: dependencies{ //https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-websocket implementation group: 'org.springframework.boot', name: 'spring-boot-starter-websocket', version: '2.3.8.RELEASE' }

控制器:

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.messaging.simp.SimpMessagingTemplate

class MessageController {
    static responseFormats = ['json', 'xml']

    //@Autowired is important and needed for intializing SimpleMessagingTemplate
    @Autowired
    SimpMessagingTemplate simpMessagingTemplate;

    def sendToUser(){
        println("send to user")
        simpMessagingTemplate.convertAndSend("/topic/user_abc", "hello from grails message controller")
        render status: 201
    }
}

尝试使用 spring-boot-starter-websocket 插件时有人遇到此错误吗?尝试了一些来自互联网的解决方案,但仍然存在相同的错误。它在 macbook 上运行良好,但是一旦我将代码移动到 Windows 中,尝试引导运行应用程序时它会一直出现此错误。

标签: javaspringspring-bootgradleintellij-idea

解决方案


推荐阅读