RJo*_*RJo 2 rest spring-batch spring-boot
我有一个使用Spring Boot开发的批处理应用程序.我的批处理应用程序需要依赖关系spring-boot-starter-web.具体来说,我需要一个REST客户端spring-hateoas和jackson-databind支持.如何禁用嵌入式Tomcat启动?我需要使用什么排除?
@EnableAutoConfiguration(excludes = {
/** What do I need to put here? */
})
@EnableBatchProcessing
@EnableConfigurationProperties
@ComponentScan
public class MyBatchApplication {
public static void main(String... args) {
SpringApplication.run(MyBatchApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
至少,这些还不够,因为它以一个例外结束:
@EnableAutoConfiguration(exclude = {
EmbeddedServletContainerAutoConfiguration.class,
WebMvcAutoConfiguration.class,
EmbeddedTomcat.class,
DispatcherServletAutoConfiguration.class
})
Run Code Online (Sandbox Code Playgroud)
例外是:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
Run Code Online (Sandbox Code Playgroud)
您可以在创建应用程序时明确禁用Web支持.这意味着您不需要排除任何自动配置:
@EnableAutoConfiguration
@EnableBatchProcessing
@EnableConfigurationProperties
@ComponentScan
public class MyBatchApplication {
public static void main(String... args) {
new SpringApplicationBuilder(MyBatchApplication.class).web(false).run(args);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1035 次 |
| 最近记录: |