= Camel Maven Plugin

The
https://github.com/apache/camel/tree/main/tooling/maven/camel-maven-plugin[Camel
Maven Plugin] allows you to run your
xref:{eip-vc}:eips:enterprise-integration-patterns.adoc[Enterprise Integration
Patterns] using xref:spring.adoc[Spring] for
xref:dependency-injection.adoc[Dependency Injection] inside Maven.

== Goals Supported

[width="100%",cols="34%,33%,33%",options="header",]
|=======================================================================
|Documentation |Goal |Description
|xref:camel-run-maven-goal.adoc[camel:run] |camel:run |Boots up Camel in
the context of a separately initiated Java thread using the
xref:spring.adoc[Spring] configuration at *META-INF/spring/*.xml* and
runs your routing rules. From Camel 2.10 onwards also OSGi blueprint is
supported to load from *OSGI-INF/blueprint/*.xml* (requires to configure
the plugin to use blueprint).

|=======================================================================

== Adding the plugin to your pom.xml

Add the following in your <build><plugins> section

[NOTE]
====


You may override the default Spring application context file uri
*META-INF/spring/*.xml* by using the applicationContextUri property in
the camel-maven-plugin configuration. Paths may be split using a
semi-colon (;).

====

[source,xml]
----
<plugin>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-maven-plugin</artifactId>
  <configuration>
    <applicationContextUri>META-INF/spring/*.xml;YOUR_FILE_NAME_IN_THE_CLASS_PATH.xml</applicationContextUri>
  </configuration>
</plugin>
----

You can also specify what Main class to use when running the plugin. By
default this is `org.apache.camel.spring.Main`.

[source,xml]
----
<plugin>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-maven-plugin</artifactId>
  <!-- optional, default value: org.apache.camel.spring.Main -->
  <configuration>
    <mainClass>mypackage.boot.camel.CamelStartup</mainClass>
  </configuration>
</plugin>
----

== File based spring configuration files

From Camel 1.4 onwards loading Spring context files via a file location
is also supported. You configure this with the
*fileApplicationContextUri* option. Paths may be split using a
semi-colon (;). This sort of file location is useful for web application
projects that store spring configuration files in WEB-INF. It can also
be used to replace configuration that requires an OSGi container with an
equivalent non-OSGi configuration.

[source,xml]
----
<plugin>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-maven-plugin</artifactId>
  <configuration>
    <fileApplicationContextUri>
      src/main/webapp/WEB-INF/camel*.xml;
      src/test/spring/test-context.xml
    </fileApplicationContextUri>
  </configuration>
</plugin>
----

