0

The thing is that have a project that uses a configuration class to get all the config properties

   @Configuration
   @PropertySource("file:/external/path/config/config.properties")
   public class AppSettings {
        @Value("${SOME.PROPERTY}")
        public String SOME_PROPERTY;
   }

So in my test configuration class I just replace the properties using this:

@TestPropertySource("classpath:testconfig.properties")

So it's work (in my local), it replace the config by the testconfig. But when i deploy it in the certification environment it throws FileNotFoundException: /external/path/config/config.properties this config.properties is in an external path, so the deploy can not access to that path.

that testconfig.properties is inside the project so I need to read this instead of the config.properties ...but is still reading it and throwing error.

How can i replace the config.properties properly when I run test?

ernstr
  • 11
  • 3

1 Answers1

0

Try to add dot after :

@PropertySource("file:./server/path/config/config.properties")

Also take a look at this chapter of spring documentation, it might be useful for you.

Kamil W
  • 2,230
  • 2
  • 21
  • 43
  • thanks but the path is good. What i'm trying to say is that i don't want to read that path when I run the test. because in that environment who deploy the app can not access to external paths. – ernstr Oct 08 '18 at 18:50