敲了一个小例子,改了两个多小时错误
一、test没有run函数,无法测试,原因导错了包,应该是
import org.junit.jupiter.api.Test;
而我导入了
import org.junit.Test;

改正后还是报错
Description:
Failed to bind properties under 'person.dog' to com.example.pojo.Dog:
Reason: No converter found capable of converting from type [java.lang.String] to type [com.example.pojo.Dog]
Action:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'person.dog' to com.example.pojo.Dog
等等一系列的错误,继续检查,发现是yaml文件里的属性缩进,空格有误。一定要注意yaml文件的语法格式,报的错真的是找不到头绪。
解决Java单元测试与配置问题
本文记录了一次Java单元测试中的常见问题及其解决过程,包括导入正确的测试包、配置YAML文件等步骤,帮助读者避免类似的错误。
1613

被折叠的 条评论
为什么被折叠?



