07-30-2023, 10:54 AM
I was having this problem. If I did a "Rebuild" from IntelliJ it would copy the application.properties from my src/test/reources folder to my target/test-classes and things would work. But, if I built from Maven, it would disappear from the target/test-classes folder and then the tests would fail when run by maven because it couldn't find the application.properties file. Low and behold, after much back and forth, I realized that my folder was named incorrectly (above is not a typo). I had "src/test/reources/application.properties" instead of "src/test/resources/application.properties". What a pain to spot that. The above answers helped me hone in on it and finally notice the typo. Was not as obvious as one might think. Watch out for that.