1

Test class:

@RunWith(SpringRunner.class)
@SpringBootTest
public class FileInterfaceTest {
 @Test
 public void contextLoads() {
 }

}

Application :

AppConfig:

      @Configuration
      @ImportResource({ "classpath:process-flows.xml" })
      public class AppConfig {
               }

Have Bootstraploader class.

Error:

       java.lang.IllegalStateException: Failed to load ApplicationContext
       Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [file.properties] cannot be opened because it does not exist

Resources loaction:

  src/main/resources
          ---process-flow.xml
          --- process.yml
  src/main/resources/env/cconfig
          --- file.properties
Jessie
  • 963
  • 5
  • 16
  • 26

2 Answers2

0

Your folder structure contains a typo: src/main/resources/env/cconfig has to be src/main/resources/env/config

As defined in the Spring Externalized Configuration, SpringApplication loads properties from application.properties files in the following locations and adds them to the Spring Environment:

  • A /config subdirectory of the current directory
  • The current directory
  • A classpath /config package
  • The classpath root
git-flo
  • 1,044
  • 13
  • 23
0

Apart from "cconfig" folder name (not sure if that was a typo) I also see your @ImportResource is mentioned as classpath:process-flows.xml however your resources folder has file named process-flow.xml

If that was not a typo as well, please add an 's' by renaming process-flow.xml to process-flows.xml and retry

Ashish Mishra
  • 303
  • 4
  • 10