Używam spring-boot
i dodano zależność spring-web
w maven pom, aby skorzystać z RestTemplate
.Jak zapobiec automatycznej konfiguracji wiosennego rozruchu w sieci wiosennej?
Teraz wiosna próbuje zainicjować EmbeddedServletContext
. Jak mogę temu zapobiec?
Exception in thread "main" 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.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 8 more
Próbowałem '@EnableAutoConfiguration (exclude = WebMvcAutoConfiguration.class, EmbeddedServletContainerAutoConfiguration.class})' ale nadal ten sam błąd ... Byłoby miło, gdyby automatyczna konfiguracja 'spring-web' mogła zostać wyłączona przez adnotację bez konieczności modyfikacji moja główna metoda startowa ... – membersound
Chociaż Twoja sugestia działa, dziękuję! Ale w każdym razie dobrze byłoby wyłączyć tylko adnotację autokonfiguracji. – membersound
"Spring.main.web_environment = false' jest jednak lepszy ... Nie ma potrzeby kodowania żadnej Javy :-) –