2017-08-06 139 views
0

我遇到了一些麻烦部署春季引导+的WebSocket +践踏在春季导游提供教程Tomcat服务器配置弹簧引导+的WebSocket +践踏在Tomcat

我使用gradle这个创造了战争,我有以下dependencie

"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") 
} 

基本上我只加了弹簧引导起动tomcat的依赖,战争和想法的插件。

的代码是一个可以在这里https://spring.io/guides/gs/messaging-stomp-websocket/

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

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

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

谢谢

回答

0

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

您可以从代码中设置上下文路径。看到这个answer

如果上下文都正确,您应该查看服务器日志查找可能阻止部署的错误。

+0

上下文是正确的,因为我已经完成了另一个应用程序的部署并且正常工作。上下文等于war文件的名称。 当我看日志时没有错误,只有日志记录发生变化。添加以下行: 0:0:0:0:0:0:0:1 - - [07/Aug/2017:09:54:58 +0100]“GET/complete/HTTP/1.1”404 1012 –