Failed to convert property value of type 'java.lang.String' to required type 'int' for property
junit + Spring 测试Service
org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'initialSize'; nested exception is java.lang.NumberFormatException: For input string: "${jdbc.initialSize}"
文件目录:
报错原因:不同的环境的参数不同。开发环境在development包下,测试环境在test包下,生产环境在production包下
在junit测试类中,无法找到所需参数需要到哪个包下查找
解决办法:@ActiveProfiles 来指定测试类加载的配置包
示例图解:
了解更多:https://blog.****.net/zhu_tianwei/article/details/46328343