Spring Boot应用程序中的Websocket - 获取403禁止
当我在eclipse(没有弹簧启动)中运行时,我可以使用sockjs/stompjs从客户端连接到websocket.
但是当我为websocket代码创建一个Spring启动jar(gradlew build)并运行java -jar websocket-code.jar时,我得到403错误连接到websocket.
我没有websockets的身份验证.我有一个CORS过滤器,并认为请求/响应中的所有标题正确.
下面是我的build.gradle
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile "org.springframework:spring-web:$spring_version"
compile "org.springframework:spring-webmvc:$spring_version"
compile "org.springframework:spring-websocket:$spring_version"
compile "org.springframework:spring-messaging:$spring_version"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-starter-web"
compile "com.fasterxml.jackson.core:jackson-databind:2.6.2"
compile "com.fasterxml.jackson.core:jackson-core:2.6.2"
compile "com.fasterxml.jackson.core:jackson-annotations:2.6.2"
compile "org.springframework.amqp:spring-rabbit:1.3.5.RELEASE"
compile("org.springframework:spring-tx")
compile("org.springframework.boot:spring-boot-starter-web:1.2.6.RELEASE")
compile("org.springframework.boot:spring-boot-starter-jetty:1.2.6.RELEASE")
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile …Run Code Online (Sandbox Code Playgroud) 我想嘲笑最后一堂课
PowerMockito.mockStatic(TestFinalClass.class);
Run Code Online (Sandbox Code Playgroud)
当我运行单个junit并将javaagent添加到我的VM参数时,它正在从我的eclipse开始工作
-javaagent:{path}/powermock-module-javaagent-1.6.4.jar
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用maven build命令从命令行运行所有测试用例时,我仍然得到"无法继承最终类"
下面是我从pom.xml获取的代码片段
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration>
<argLine>-javaagent:{path}/powermock-module-javaagent-1.6.4.jar</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)