Java基础学习总结(130)——使用WebSocket导致jUnit单元测试报No suitable default RequestUpgradeStrategy found错误的解决方法

若在SpringMVC项目中使用了WebSocket,在运行jUnit单元测试时,可能会报如下错误:

Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found

若出现上述异常,在Maven的pom.xml中添加如下依赖,问题即可解决:

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>7.0.52</version>
<scope>test</scope>
</dependency>

异常详情如下截图所示:

在pom.xml文件中现在依赖:

idea java:无效的标记: -parameters

12-27

最近在学springboot,写了一个测试代码结果报错 ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ggr.springboot2</groupId> <artifactId>springboot2-hello</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <!-- springboot 2.0 parent 工程依赖 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <!-- spring MVC 依赖 --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <build> <finalName>springboot2-hello</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.0.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.10</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.0</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build> </project> ``` ``` @SpringBootApplication public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } } ``` 报错日志只有这4个 ``` Information:java: Errors occurred while compiling module 'springboot2hello' Information:javac 7 was used to compile java sources Information:2018/12/27 13:21 - Compilation completed with 1 error and 0 warnings in 11 s 624 ms Error:java: 无效的标记: -parameters ``` 报错信息显示: Error:java: 无效的标记: -parameters 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览

应支付9.90元
点击重新获取
扫码支付

支付成功即可阅读