Can not extend SpringBootServletInitializer while using Apache-Camel Spring starter


Can not extend SpringBootServletInitializer while using Apache-Camel Spring starter



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.


The type org.springframework.web.WebApplicationInitializer cannot be resolved. It is indirectly referenced from required .class files


SpringBootServletInitializer.class


spring-boot-1.5.10.RELEASE


camel-spring-boot-starter



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.


spring-boot-starter-web


camel-spring-boot-starter


spring-boot-starter-web




2 Answers
2



I found my solution, it was definitely problem with spring-boot version i was using, version below 2 works fine, did hot have time to research though why version 2.. is not working.



You need to update your camel version for Spring Boot 2 compatibility.



https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/main/docs/spring-boot.adoc



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.


spring-boot-starter-web


spring-boot-starter-webflux






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV