Minimales Beispiel für einen Apache-Camel Jetty-basierten Serverarbeit machen
Posted: 07 Feb 2025, 08:01
Ich möchte eine REST -Schnittstelle zu einer Datenbank mithilfe der Jettkomponente von Apache Camel erstellen. Ich kämpfe jedoch mit den ersten Schritten, daher möchte ich ein minimales Beispiel funktionieren. < /P>
Ich habe eine Komponentenklasse: < /p>
Variante 1 verursacht eine Curl http: // localhost: 8080/ mit "Versäumnis, eine Verbindung zum Localhost -Port 8080: Verbindung abgelehnt"
Variante 2 verursacht Ausnahme < /p>
Der Webserver kann nicht starten. Eine verschachtelte Ausnahme ist org.springframework.boot.web.context.missingweberverfactoryBeanException: Keine Qualifikation von Typ 'org.springframework ean
< /blockquote>
POM -Abhängigkeiten: < /p>
org.apache.camel.springboot
camel-servlet-starter
org.apache.camel
camel-jetty
org.apache.camel.springboot
camel-jetty-starter
org.springframework.boot
spring-boot-starter-web
< /code>
Ich muss zugeben, dass ich nicht verstanden habe, wie Springboot und all dies funktioniert. Deshalb kopierte ich so weit, aber jetzt brauche ich einige Anleitung. Wie kann
Ich habe eine Komponentenklasse: < /p>
Code: Select all
@Component
public class myRouteBuilder extends RouteBuilder {
from("jetty:http://0.0.0.0:8080/").log("Request received.").setBody(simple("Huhu y'all!"));
}
< /code>
, der von einer Springboot -Starterklasse gestartet wird: < /p>
@SpringBootApplication
public class RestServiceApplication {
private static CountDownLatch _stopLatch = null;
public static void main(String[] args) {
SpringApplication theApp = new SpringApplication(myRouteBuilder.class);
// variant 1 causing to happen nothing
theApp.setWebApplicationType(WebApplicationType.NONE);
// variant 2 causing an execption
theApp.setWebApplicationType(WebApplicationType.SERVLET);
try {
ConfigurableApplicationContext appContext = theApp.run();
appContext.registerShutdownHook();
} catch (Exception e) {
...
return;
}
_stopLatch = new CountDownLatch(1);
try {
_stopLatch.await();
} catch (InterruptedException e) {
...
}
}
}
Variante 2 verursacht Ausnahme < /p>
Der Webserver kann nicht starten. Eine verschachtelte Ausnahme ist org.springframework.boot.web.context.missingweberverfactoryBeanException: Keine Qualifikation von Typ 'org.springframework ean
< /blockquote>
POM -Abhängigkeiten: < /p>
org.apache.camel.springboot
camel-servlet-starter
org.apache.camel
camel-jetty
org.apache.camel.springboot
camel-jetty-starter
org.springframework.boot
spring-boot-starter-web
< /code>
Ich muss zugeben, dass ich nicht verstanden habe, wie Springboot und all dies funktioniert. Deshalb kopierte ich so weit, aber jetzt brauche ich einige Anleitung. Wie kann