【问题标题】:gradle tomcat plugin not starting websocketgradle tomcat插件没有启动websocket
【发布时间】:2016-11-09 21:52:44
【问题描述】:

我正在使用带有此配置的 bmuschko tomcat 插件

apply plugin: 'java' apply plugin: 'war' apply plugin: 'com.bmuschko.tomcat'

configurations {
    provided 
}

repositories {
    mavenCentral() }

tomcat {
    httpPort = 8001
    contextPath = "/"
}

dependencies {
    compile 'junit:junit:4.12'

    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
    compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
    compile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
    compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.1.0.Final'

    compileOnly group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'

    def tomcatVersion = '7.0.59'
    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
        "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
        "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
 }

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.5'
    }
}

但在 Chrome 中仍然出现此错误

与“ws://localhost:8001/test”的 WebSocket 连接失败:WebSocket 握手期间出错:意外响应代码:404

我假设 Serverendpoint 没有启动。然而 Servlet 照常启动

【问题讨论】:

    标签: java tomcat gradle websocket


    【解决方案1】:

    似乎是 gradle tomcat 插件的问题。我现在正在使用 gretty,效果很好。

    【讨论】:

      【解决方案2】:

      我有同样的问题。我使用tomcatRunWar 任务而不是tomcatRun 任务启动了服务器,它开始工作了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-07-20
        • 2012-11-29
        • 1970-01-01
        • 2014-01-14
        • 2020-08-04
        • 2012-05-29
        • 1970-01-01
        相关资源
        最近更新 更多