I am trying to create a deployable *.war from a Spring Boot application by following their documentation. I am having problem while extending SpringBootServletInitializer. It's giving me a compile time error saying The type org.springframework.web.WebApplicationInitializer cannot be resolved. It is indirectly referenced from required .class files
. But in the Maven dependency directory I can clearly see SpringBootServletInitializer.class
exists in spring-boot-1.5.10.RELEASE
jar. It was downloaded as part of the camel-spring-boot-starter
dependency.
My Main class
@SpringBootApplication
@EnableAutoConfiguration
public class SpringCamelApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(SpringCamelApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringCamelApplication.class);
}
@Bean
public RestConfiguration restConfiguration()
{
RestConfiguration restconfig=new RestConfiguration();
restconfig.setPort(8081);
restconfig.setComponent("restlet");
//restconfig.setHost("localhost");
restconfig.setContextPath("/api");
restconfig.setBindingMode("auto");
return restconfig;
}
}
My pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.camel</groupId>
<artifactId>spring-camel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-camel</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<camel.version>2.21.0</camel.version>
<spring.version>2.0.0.RELEASE</spring.version>
<start-class>com.camel.springcamel.SpringCamelApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>${camel.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Where am I going wrong here? I have noticed if I use spring-boot-starter-web
dependency then this doesn't give me any error, but I already have camel-spring-boot-starter
so I shouldn't need spring-boot-starter-web
. Can anybody explain what is actually wrong here? Thanks in advance.
You need to update your camel version for Spring Boot 2 compatibility.
Spring Boot 2 is supported since Camel 2.22 (summer 2018). Previous versions of Camel support Spring Boot 1.x only.
Also as of Spring Boot 2 spring-boot-starter-web
is no longer a transitive dependency in Spring Starters due to the addition of spring-boot-starter-webflux
for reactive impls of HTTP and WebSockets. It's up to third parties, or yourself, to decide on what implementation to pick.