【发布时间】:2018-08-28 23:57:39
【问题描述】:
我需要将应用程序从 spring-boot-1.2.5.RELEASE 升级到 spring-boot-2.0.0.RELEASE。
我有以下代码:
@Configuration
@ComponentScan
@EnableAutoConfiguration(exclude = {HibernateJpaAutoConfiguration.class, RedisAutoConfiguration.class})
public class NiceBootApplicationWithoutDB extends AbstractBootApplication {
public static final String APPLICATION_CONTEXT_XML = "classpath:/META-INF/application-context-nodb.xml";
public static void main(String[] args) {
SpringApplication.run(APPLICATION_CONTEXT_XML, getFullArgList(args));
}
}
SpringApplication.run(APPLICATION_CONTEXT_XML, getFullArgList(args)) 的重载是:
/**
* Static helper that can be used to run a {@link SpringApplication} from the
* specified source using default settings.
* @param source the source to load
* @param args the application arguments (usually passed from a Java main method)
* @return the running {@link ApplicationContext}
*/
public static ConfigurableApplicationContext run(Object source, String... args) {
return run(new Object[] { source }, args);
}
/**
* Static helper that can be used to run a {@link SpringApplication} from the
* specified sources using default settings and user supplied arguments.
* @param sources the sources to load
* @param args the application arguments (usually passed from a Java main method)
* @return the running {@link ApplicationContext}
*/
public static ConfigurableApplicationContext run(Object[] sources, String[] args) {
return new SpringApplication(sources).run(args);
}
spring-boot-2.0.0.RELEASE 中不存在这两个重载。
我的问题是——如何升级以上代码?
【问题讨论】:
-
SpringApplication constructor 和 run 方法现在使用
Class<?>[] primarySources参数...你试过了吗?
标签: java spring spring-boot