LoginSignup
0
1

More than 5 years have passed since last update.

SpringBootApplicationが無くてUnable to start ServletWebServerApplicationContext

Posted at

@SpringBootApplicationをつけずに実行するとこの例外がスローされる。

//@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]

メッセージが示すようにServletWebServerFactory beanが何らかの要因でcontext上にロードされていないとこのエラーになる。spring-bootの場合はautoconfigに頼ってれば、@SpringBootApplicationを付け忘れとかの凡ミスを除けば、問題ない。それ以外の場合は手作業でbeanを登録してやることになるかと。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1