我在部署Spring Boot + WebSocket + Stomp教程时遇到了一些问题,这些教程可以在Tomcat Server的spring指南中找到
我正在使用gradle创建war,其中我有以下依赖项
"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 (未找到)”
我能做些什么来让它工作呢?
谢谢
发布于 2017-08-06 22:31:35
首先,确保使用正确的上下文路径部署WAR。您提到的示例代码假定您将代码部署到根路径- http://localhost:8080
您可以从代码中设置上下文路径。请参阅此answer。
如果上下文中的所有内容都是正确的,那么您应该查看服务器日志中可能阻止部署的错误。
https://stackoverflow.com/questions/45532981
复制相似问题