Reputation: 19854
I've successfully managed to create a Spring boot application that runs as a Java application as follows:
@SpringBootApplication
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication springApplication = new SpringApplication();
springApplication.setWebEnvironment(false);
springApplication.run(Application.class, args);
}
The problem is that my application requires the spring-web
module as it is a client to a REST service.
Once I add the spring-web
module I get an error:
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
How can I get it to run as a Java application with spring-web
on the classpath
Upvotes: 3
Views: 1568
Reputation: 4683
I have "same setup" as you - command line spring boot app that uses RestTemplate
from spring-web
and everything works well. Maybe it is just that I use "full" spring web starter.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
(and just slightly different main but it shouldn't be a difference)
SpringApplication app = new SpringApplication(MyApplication.class);
app.setWebEnvironment(false);
app.run(args);
Upvotes: 1