diff --git a/spring-boot-modules/spring-boot-camel/pom.xml b/spring-boot-modules/spring-boot-camel/pom.xml
index 881b021b96..46a90b4722 100644
--- a/spring-boot-modules/spring-boot-camel/pom.xml
+++ b/spring-boot-modules/spring-boot-camel/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -38,12 +38,10 @@
org.springframework.boot
spring-boot-starter-web
- ${spring-boot-starter.version}
org.springframework.boot
spring-boot-starter-test
- ${spring-boot-starter.version}
test
@@ -55,7 +53,6 @@
org.springframework.boot
spring-boot-maven-plugin
- ${spring-boot-starter.version}
@@ -68,8 +65,7 @@
- 2.19.1
- 1.5.4.RELEASE
+ 3.0.0-M4
diff --git a/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java
index aadd37a3b4..48294e9c56 100644
--- a/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java
+++ b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java
@@ -12,33 +12,36 @@ import org.apache.camel.model.rest.RestBindingMode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
+import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration;
+import org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration;
+import org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
-@SpringBootApplication
-@ComponentScan(basePackages="com.baeldung.camel")
-public class Application{
+@SpringBootApplication(exclude = { WebSocketServletAutoConfiguration.class, AopAutoConfiguration.class, OAuth2ResourceServerAutoConfiguration.class, EmbeddedWebServerFactoryCustomizerAutoConfiguration.class })
+@ComponentScan(basePackages = "com.baeldung.camel")
+public class Application {
@Value("${server.port}")
String serverPort;
-
+
@Value("${baeldung.api.path}")
String contextPath;
-
+
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
ServletRegistrationBean servletRegistrationBean() {
- ServletRegistrationBean servlet = new ServletRegistrationBean(new CamelHttpTransportServlet(), contextPath+"/*");
+ ServletRegistrationBean servlet = new ServletRegistrationBean(new CamelHttpTransportServlet(), contextPath + "/*");
servlet.setName("CamelServlet");
return servlet;
}
-
@Component
class RestApi extends RouteBuilder {
@@ -47,7 +50,6 @@ public class Application{
CamelContext context = new DefaultCamelContext();
-
// http://localhost:8080/camel/api-doc
restConfiguration().contextPath(contextPath) //
.port(serverPort)
@@ -60,43 +62,43 @@ public class Application{
.component("servlet")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("prettyPrint", "true");
-/**
-The Rest DSL supports automatic binding json/xml contents to/from
-POJOs using Camels Data Format.
-By default the binding mode is off, meaning there is no automatic
-binding happening for incoming and outgoing messages.
-You may want to use binding if you develop POJOs that maps to
-your REST services request and response types.
-*/
-
+ /**
+ The Rest DSL supports automatic binding json/xml contents to/from
+ POJOs using Camels Data Format.
+ By default the binding mode is off, meaning there is no automatic
+ binding happening for incoming and outgoing messages.
+ You may want to use binding if you develop POJOs that maps to
+ your REST services request and response types.
+ */
+
rest("/api/").description("Teste REST Service")
.id("api-route")
.post("/bean")
.produces(MediaType.APPLICATION_JSON)
.consumes(MediaType.APPLICATION_JSON)
-// .get("/hello/{place}")
+ // .get("/hello/{place}")
.bindingMode(RestBindingMode.auto)
.type(MyBean.class)
.enableCORS(true)
-// .outType(OutBean.class)
+ // .outType(OutBean.class)
.to("direct:remoteService");
-
-
- from("direct:remoteService")
- .routeId("direct-route")
+
+ from("direct:remoteService").routeId("direct-route")
.tracing()
.log(">>> ${body.id}")
.log(">>> ${body.name}")
-// .transform().simple("blue ${in.body.name}")
+ // .transform().simple("blue ${in.body.name}")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- MyBean bodyIn = (MyBean) exchange.getIn().getBody();
-
+ MyBean bodyIn = (MyBean) exchange.getIn()
+ .getBody();
+
ExampleServices.example(bodyIn);
- exchange.getIn().setBody(bodyIn);
+ exchange.getIn()
+ .setBody(bodyIn);
}
})
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(201));
diff --git a/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties b/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties
index bce95f8eaf..29fee8cff6 100644
--- a/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties
+++ b/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties
@@ -12,4 +12,6 @@ management.port=8081
# disable all management enpoints except health
endpoints.enabled = true
-endpoints.health.enabled = true
\ No newline at end of file
+endpoints.health.enabled = true
+
+spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-camel/src/test/java/com/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-camel/src/test/java/com/baeldung/SpringContextTest.java