Код для компиляции и выполнения файла:
- mvn clean package
- mvn camel:run -Dcamel.main.durationMaxMessages=2
Содержание моего файла POM: < /p>
4.0.0
org.apache.camel.learn
first-camel-integration
jar
1.0.0-SNAPSHOT
A Camel Route
UTF-8
UTF-8
2.13.3
org.apache.camel
camel-bom
3.18.4
import
pom
org.apache.camel
camel-core
3.20.0
org.apache.camel
camel-main
3.20.0
org.apache.logging.log4j
log4j-slf4j-impl
runtime
${log4j2-version}
org.apache.camel
camel-test
test
org.apache.camel
camel-jsonpath
3.20.0
org.apache.camel
camel-jackson
3.20.0
install
org.apache.maven.plugins
maven-compiler-plugin
3.10.1
11
org.apache.maven.plugins
maven-resources-plugin
3.2.0
UTF-8
org.apache.camel
camel-maven-plugin
3.20.0
true
org.apache.camel.learn.MainApp
< /code>
mainapp.java < /p>
package org.apache.camel.learn;
import org.apache.camel.main.Main;
public class MainApp {
/**
* A main() so we can easily run these routing rules in our IDE
*/
public static void main(String... args) throws Exception {
Main main = new Main();
main.configure().addRoutesBuilder(new MyRouteBuilder());
main.run(args);
}
}
< /code>
myroutebuilder.java
package org.apache.camel.learn;
import org.apache.camel.builder.RouteBuilder;
public class MyRouteBuilder extends RouteBuilder {
/**
* Let's configure the Camel routing rules using Java code...
*/
public void configure() {
// here is a sample which processes the input files
// (leaving them in place - see the 'noop' flag)
// then performs content based routing on the message using XPath
from("file:src/data?noop=true")
.choice()
.when(simple("${file:ext} == 'xml'"))
.choice()
.when(xpath("/person/city = 'London'"))
.log("UK message")
.to("file:target/messages/uk")
.when(xpath("/person/city = 'Mumbai'"))
.log("India message")
.to("file:target/messages/india")
.otherwise()
.log("Other message")
.to("file:target/messages/others")
.end()
.when(simple("${file:ext} == 'json'"))
.unmarshal().json(JsonLibrary.Jackson) // Convert JSON to Java Object
.choice()
.when().jsonpath("$.person.city == 'London'")
.log("UK message")
.to("file:target/messages/uk")
.when().jsonpath("$.person.city == 'Mumbai'")
.log("India message")
.to("file:target/messages/india")
.otherwise()
.log("Other message")
.to("file:target/messages/others")
.end()
.otherwise()
.log("Unsupported file type")
.to("file:target/messages/others")
.end();
}
}
< /code>
ошибка i get: < /p>
[ERROR] *************************************
[ERROR] Error occurred while running main from: org.apache.camel.learn.MainApp
[ERROR]
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:118)
at java.lang.reflect.Method.invoke (Method.java:580)
at org.apache.camel.maven.RunMojo$1.run (RunMojo.java:412)
at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.NoClassDefFoundError: org/apache/camel/vault/HashicorpVaultConfiguration
at org.apache.camel.learn.MainApp.main (MainApp.java:14)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
at java.lang.reflect.Method.invoke (Method.java:580)
at org.apache.camel.maven.RunMojo$1.run (RunMojo.java:412)
at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: org.apache.camel.vault.HashicorpVaultConfiguration
at java.net.URLClassLoader.findClass (URLClassLoader.java:445)
at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
at org.apache.camel.learn.MainApp.main (MainApp.java:14)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
at java.lang.reflect.Method.invoke (Method.java:580)
at org.apache.camel.maven.RunMojo$1.run (RunMojo.java:412)
at java.lang.Thread.run (Thread.java:1583)
[ERROR] *************************************
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.774 s
[INFO] Finished at: 2025-02-06T16:19:56+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:3.20.0:run (default-cli) on project first-camel-integration: null: MojoExecutionException: InvocationTargetException: org/apache/camel/vault/HashicorpVaultConfiguration: org.apache.camel.vault.HashicorpVaultConfiguration -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/disp ... nException
Подробнее здесь: https://stackoverflow.com/questions/794 ... un-command