junit中使用 @value 流秧 2022-01-02 4,177 阅读1分钟 解决方案 第一种 在test资源文件下,添加配置文件,配置文件的profile定位test(test这个名字自定义) 在对应的单元测试的类上加上注解@activeProfile(value="test") 第二种 加上TestPropertySource注解,然后将之前@value映射的路径,写在properties中就可以了 参考 Populating Spring @Value during Unit Test