run classpath in external folder war file command Spring java
<p>I have a war package and wanted to include an external classpath:</p>

<p>in my controller:</p>

<p>I have this following code:</p>

<p><strong>WebApplication class:</strong></p>

<pre><code>@SpringBootApplication
@PropertySource( "classpath:config.properties" )
public class WebApplication{

   public static void main(String[] args){
        SpringApplication.run(WebApplication.class, args);
   }
}
</code></pre>

<p><strong>Controller Class:</strong></p>

<pre><code>@Controller
@PropertySource( "classpath:config.properties" )
public class ApplicationController{

     //doing some stuff here

}
</code></pre>

<p>my folder:</p>

<blockquote>
  <p>|-project</p>

<pre><code>|-src
   |-main
     |-java
       |-com.mypage.temp
         |-WebApplication.java (main class)
       |-com.mypage.temp.controller
         |-ApplicationController (Controller)
     |-resources
       |- [some stuff &amp; not putting my properties file here to include externally]
     |-deploy
       |-config.properties
</code></pre>
</blockquote>

<p>However when I build</p>

<blockquote>
  <p>project.war</p>
</blockquote>

<p>I put in a remote server (unix):</p>

<blockquote>
  <p>|project</p>

<pre><code>  |-bin
    |-project.war
  |-config
    |-config.properties
</code></pre>
  
  <p>Something/something/something/bin/project.war
  Something/something/something/config/config.properties</p>
</blockquote>

<p>run command:</p>

<blockquote>
  <p>java -jar -Dclasspath=/something/something/something/config/config.properties project.war</p>
</blockquote>

<p>Error:</p>

<pre><code> Failed to parse configuration class [com.mypage.temp.WebApplication];
 nested exception is java.io.FileNotFoundException: class path resource
 [config.properties] cannot be opened because it does not exist
 2016-12-19 18:13:16.763 ERROR 21662 --- [           main]
 o.s.boot.SpringApplication               : Application startup failed

 org.springframework.beans.factory.BeanDefinitionStoreException: Failed to
 parse configuration class [com.mypage.temp.WebApplication]; nested
 exception is java.io.FileNotFoundException: class path resource
 [config.properties] cannot be opened because it does not exist
</code></pre>