Java IntelliJ中的单个单元测试找不到Spring.properties文件
在IntelliJ中运行单个JUnit测试时,使用Java IntelliJ中的单个单元测试找不到Spring.properties文件,java,spring,junit,Java,Spring,Junit,在IntelliJ中运行单个JUnit测试时,使用@SpringJUnit4ClassRunner和指向test-context-spring.xml的@ContextConfiguration,启动时出现以下异常: TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property ${...} 经过多次努力,以及几个毫无帮
@SpringJUnit4ClassRunner
和指向test-context-spring.xml的@ContextConfiguration
,启动时出现以下异常:
TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property ${...}
经过多次努力,以及几个毫无帮助的堆栈溢出答案(表明Spring找到了不止一个.properties文件),我决定通过Eclipse运行相同的测试。低,看它的工作 所以这是一个智力问题。解决:
文件>项目结构>模块>(选择您的模块)>来源
在Sources下,做两件事:
再次运行测试。它应该可以找到属性文件。听起来好像您没有作为Maven/Gradle项目导入;这应该是自动发生的。