当它收到第一个请求时,它会启动 dispatcherServlet 2次。然后,对此应用的所有请求都会提供2次。它发生在Linux上,而不是在Windows上。记录下面的条目:
[2016-01-20 10:52:39.125] boot - 3367 INFO [http-nio-8090-exec-1] --- [/]: Initializing Spring FrameworkServlet 'dispatcherServlet'
[2016-01-20 10:52:39.125] boot - 3367 INFO [http-nio-8090-exec-1] --- [/]: Initializing Spring FrameworkServlet 'dispatcherServlet'
[2016-01-20 10:52:39.129] boot - 3367 INFO [http-nio-8090-exec-1] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization started
[2016-01-20 10:52:39.129] boot - 3367 INFO [http-nio-8090-exec-1] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization started
[2016-01-20 10:52:39.156] boot - 3367 INFO [http-nio-8090-exec-1] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization completed in 27 ms
[2016-01-20 10:52:39.156] boot - 3367 INFO [http-nio-8090-exec-1] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization completed in 27 ms
App依赖于: spring-boot-starter-tomcat , spring-boot-starter-web
它是主类和控制器:
@RestController
class LogController {
public static final Logger LOG = LoggerFactory.getLogger(LogController.class);
@RequestMapping("/getErrors")
public Map<String, String> getErrors() {
//call to methods
}
}
@EnableConfigurationProperties
@SpringBootApplication
@EnableScheduling
//@EnableWebMvcSecurity
public class LogAppConfiguration {
public static void main(String[] args) {
SpringApplication.run(LogAppConfiguration.class, args);
}
}
我尝试删除 EmbeddedServletContainerFactory bean(上面未显示)。它仍然会发生。