java - 在尝试使用“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 中,尝试引导运行应用程序时它会一直出现此错误。
解决方案
推荐阅读
- java - 如何按日期和时间对列表进行排序?
- ms-access - DLOOKUP 函数多条件
- javascript - 无法调用在单独文件中定义的函数
- python-3.4 - Python 使用 RC522 写入个人用户 ID
- python - 使用 Keras 的 LSTM,输入到第一层的尺寸误差
- r - R中并行算法与顺序算法的不同结果
- apache - 如何测量将数据从 csv 文件导入 Hbase 的时间?
- laravel - 身份验证 - 在会话和基于令牌的身份验证之间共享相同的经过身份验证的用户
- reactjs - 将 react router v4 与 react 16.5.2 一起使用,在加载时收到警告并使用路由器
- .net - 从 .Net 应用程序登录到 Logstash 的最佳做法是什么?