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 .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
}
}
有没有人在尝试使用SpringBootStarterWebSocket插件时出现这个错误?从互联网上尝试了一些解决方案,但仍然有相同的错误。它在macbook上运行得很好,但是一旦我将代码移到windows中,在尝试引导运行应用程序时,它就会一直出现这个错误。
暂无答案!
目前还没有任何答案,快来回答吧!