2017-08-06 138 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 –