Spring实战(第5版)程序清单1.6运行失败解决

报错:

java.lang.AssertionError: Response content

java.lang.AssertionError: Response content
Expected: a string containing "Welcome to..."
     but: was ""

断言错误:响应内容

预期:一个包含"Welcome to..."的字符串

但(实际上是):是""

原因:

作者在home.html中声明使用Thymeleaf作为引擎模板,但是在默认的pom.xml中缺少相应的依赖,不能以预期的方式解析.

解决方法:

在pom.xml的<dependencies>中添加Thymeleaf的依赖,刷新maven,重新运行测试文件.

 <dependency>                                             <!--3 -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
 </dependency>

上一篇:vue cli 3 项目中配置env环境变量


下一篇:C语言练习题:输出带框文字