首页 文章

在Tomcat上部署Spring Boot WebSocket Stomp

提问于
浏览
0

我在部署Tomcat服务器的 spring 指南中提供的Spring Boot WebSocket Stomp教程时遇到了一些麻烦

我正在使用gradle创建战争,我有以下依赖

"build.gradle"

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.6.RELEASE")
    }
}

apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.springframework.boot'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
     mavenCentral()
}

dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '1.5.6.RELEASE'

compile("org.springframework.boot:spring-boot-starter-websocket")

compile("org.webjars:webjars-locator")
compile("org.webjars:sockjs-client:1.0.2")
compile("org.webjars:stomp-websocket:2.3.3")
compile("org.webjars:bootstrap:3.3.7")
compile("org.webjars:jquery:3.1.0")

testCompile("org.springframework.boot:spring-boot-starter-test")
}

基本上我只添加了spring-boot-starter-tomcat依赖项以及war和idea插件 .

代码是这里可用的代码https://spring.io/guides/gs/messaging-stomp-websocket/

部署后,当我尝试访问http://localhost:8080/complete/时,我收到以下错误

“无法加载资源:服务器响应状态为404(未找到)”

我能做些什么来完成这项工作?

谢谢

1 回答

  • 0

    首先,确保使用正确的上下文路径部署WAR . 您提到的示例代码假定您将代码部署到根路径 - http://localhost:8080

    您可以从代码中设置上下文路径 . 见answer .

    如果具有上下文的所有内容都正确,您应该查看服务器日志以查找可能阻止部署的错误 .

相关问题