Reputation: 1601
I have added the annotation on main class,given below:
package com.main;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.controller.RequestClass;
@CrossOrigin(origins = "http://localhost:4200")
@SpringBootApplication
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.*")
public class MainClass
{
public static void main(String[] args)
{
SpringApplication.run(RequestClass.class, args);
}
}
but on running the application , facing below error.
please let me know if require any other file to debug
2018-07-08 14:16:27.321 INFO 7832 --- [ main] com.main.MainClass : Starting MainClass on DESKTOP-551C51M with PID 7832 (C:\Users\sparsh\eclipse-workspace\firstprogram\target\classes started by sparsh in C:\Users\sparsh\eclipse-workspace\firstprogram) 2018-07-08 14:16:27.327 INFO 7832 --- [ main] com.main.MainClass : No active profile set, falling back to default profiles: default 2018-07-08 14:16:27.382 INFO 7832 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2893de87: startup date [Sun Jul 08 14:16:27 IST 2018]; root of context hierarchy 2018-07-08 14:16:27.611 WARN 7832 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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. 2018-07-08 14:16:27.974 ERROR 7832 --- [ main] o.s.boot.SpringApplication : Application run failed
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.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at com.main.MainClass.main(MainClass.java:21) [classes/:na] Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:204) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] ... 8 common frames omitted
Upvotes: 2
Views: 7740
Reputation: 127
What happens if springapplicatiom.run is against the main class not the controller class - does it start ? Take a look at this thread https://stackoverflow.com/a/44466367/5126865 (am assuming a bit about what you want to achieve so apologies if off the mark)
Upvotes: 2