我正在使用spring boot并将其部署为独立tomcat中的战争。下面是我的应用程序类。
public class APIApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
configureApplication(new SpringApplicationBuilder()).run(args);
}
public static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
return builder.sources(APIApplication .class).properties(getProperties());
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(APIApplication .class);
}
public static Properties getProperties() {
Properties props = new Properties();
props.setProperty("spring.config.location",
"/home/config_directory/");
props.setProperty("spring.config.name", "apiapplication");
return props;
}
}
但这不起作用并且不会从/home/config_directory/apiapplication.properties读取
任何帮助表示赞赏。
编辑
也试过
public static void main(String[] args) {
System.setProperty("spring.config.location","/home/config_directory/");
System.setProperty("spring.config.name", "apiapplication.properties");
SpringApplication.run(DriverguidanceapiApplication.class, args);
//configureApplication(new SpringApplicationBuilder()).run(args);
}
也没有工作。