私は戦争のパッケージを持っており、外部のクラスパス含めるしたい:私のコントローラで実行クラスパス春のJava
を:
私はこの次のコードを持っている:
のWebApplicationをクラス:
@SpringBootApplication
@PropertySource("classpath:config.properties")
public class WebApplication{
public static void main(String[] args){
SpringApplication.run(WebApplication.class, args);
}
}
コントローラクラス:
@Controller
@PropertySource("classpath:config.properties")
public class ApplicationController{
//doing some stuff here
}
私のフォルダ:私は造るしかし
|-project
|-src |-main |-java |-com.mypage.temp |-WebApplication.java (main class) |-com.mypage.temp.controller |-ApplicationController (Controller) |-resources |- [some stuff & not putting my properties file here to include externally] |-deploy |-config.properties
project.war
私はリモートサーバ(UNIX)に入れ:
|project
|-bin |-project.war |-config |-config.properties
Something/something/something/bin/project.war Something/something/something/config/config.properties
runコマンド:
java -jar -Dclasspath=/something/something/something/config/config.properties project.war
エラー:official documentationから
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
それはあなたのOSである – isme
動作しませんか? – davidxxx
Unixは私のオペレーティングシステム – isme