Repository: camel Updated Branches: refs/heads/master bbcb956f4 -> 68de41e41
CAMEL-10436: Spring Boot - Create JAR instead of WAR Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/68de41e4 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/68de41e4 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/68de41e4 Branch: refs/heads/master Commit: 68de41e411428a32bbd884633b12c7a18d6d575e Parents: a2a3741 Author: Darius <[email protected]> Authored: Thu Nov 24 14:56:44 2016 -0500 Committer: Claus Ibsen <[email protected]> Committed: Sun Nov 27 19:04:59 2016 +0100 ---------------------------------------------------------------------- examples/camel-example-spring-boot/README.md | 9 +++--- .../resources/archetype-resources/ReadMe.txt | 9 +++--- .../main/resources/archetype-resources/pom.xml | 14 +-------- .../src/main/java/MySpringBootApplication.java | 32 ++++++++++++++++++++ .../src/main/java/MySpringBootRouter.java | 8 ++--- .../java/MySpringBootRouterWarInitializer.java | 29 ------------------ 6 files changed, 45 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/examples/camel-example-spring-boot/README.md ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot/README.md b/examples/camel-example-spring-boot/README.md index d18fb2c..7401c42 100644 --- a/examples/camel-example-spring-boot/README.md +++ b/examples/camel-example-spring-boot/README.md @@ -11,9 +11,8 @@ This example exposes Jolokia API and Spring Boot actuators endpoints (like metri this as the best practice - Spring Boot applications with these API exposed can be easily monitored and managed by the 3rd parties tools. -We recommend to package your application as a fat WAR. Fat WARs can be executed just as regular fat jars, but you can also -deploy them to the servlet containers like Tomcat. Fat WAR approach gives you the deployment flexibility, so we highly -recommend it. +This example packages your application as a JAR, but you can also package as a WAR and deploy to +servlet containers like Tomcat. ### Build You will need to compile this example first: @@ -25,9 +24,9 @@ To run the example type mvn spring-boot:run -You can also execute the fat WAR directly: +You can also execute the JAR directly: - java -jar target/camel-example-spring-boot.war + java -jar target/camel-example-spring-boot.jar You will see the message printed to the console every second. http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/ReadMe.txt ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/ReadMe.txt index 4232762..8e16528 100644 --- a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/ReadMe.txt @@ -10,9 +10,8 @@ This example exposes Jolokia API and Spring Boot actuators endpoints (like metri this as the best practice - Spring Boot applications with these API exposed can be easily monitored and managed by the 3rd parties tools. -We recommend to package your application as a fat WAR. Fat WARs can be executed just as regular fat jars, but you can also -deploy them to the servlet containers like Tomcat. Fat WAR approach gives you the deployment flexibility, so we highly -recommend it. +This example packages your application as a JAR, but you can also package as a WAR and deploy to +servlet containers like Tomcat. You will need to compile this example first: mvn install @@ -20,9 +19,9 @@ You will need to compile this example first: To run the example type mvn spring-boot:run -You can also execute the fat WAR directly: +You can also execute the JAR directly: - java -jar target/${artifactId}-${version}.war + java -jar target/${artifactId}-${version}.jar You will see the message printed to the console every second. http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/pom.xml ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/pom.xml index b3d28f4..8342c35 100755 --- a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/pom.xml +++ b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/pom.xml @@ -22,7 +22,7 @@ <groupId>${groupId}</groupId> <artifactId>${artifactId}</artifactId> - <packaging>war</packaging> + <packaging>jar</packaging> <version>${version}</version> <name>A Camel Spring Boot Route</name> @@ -79,21 +79,9 @@ <build> <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <version>${maven-war-plugin-version}</version> - <configuration> - <failOnMissingWebXml>false</failOnMissingWebXml> - <attachClasses>true</attachClasses> - </configuration> - </plugin> - <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring.boot-version}</version> - <configuration> - <mainClass>org.apache.camel.spring.boot.FatJarRouter</mainClass> - </configuration> <executions> <execution> <goals> http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootApplication.java ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootApplication.java b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootApplication.java new file mode 100644 index 0000000..dc6622a --- /dev/null +++ b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootApplication.java @@ -0,0 +1,32 @@ +## ------------------------------------------------------------------------ +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## ------------------------------------------------------------------------ +package ${package}; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MySpringBootApplication { + + /** + * A main method to start this application. + */ + public static void main(String[] args) { + SpringApplication.run(MySpringBootApplication.class, args); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouter.java ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouter.java b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouter.java index 19289e9..3b65b69 100644 --- a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouter.java +++ b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouter.java @@ -16,12 +16,12 @@ ## ------------------------------------------------------------------------ package ${package}; -import org.apache.camel.spring.boot.FatJarRouter; -import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.apache.camel.builder.RouteBuilder; import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; -@SpringBootApplication -public class MySpringBootRouter extends FatJarRouter { +@Component +public class MySpringBootRouter extends RouteBuilder { @Override public void configure() { http://git-wip-us.apache.org/repos/asf/camel/blob/68de41e4/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouterWarInitializer.java ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouterWarInitializer.java b/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouterWarInitializer.java deleted file mode 100644 index 95c92a1..0000000 --- a/tooling/archetypes/camel-archetype-spring-boot/src/main/resources/archetype-resources/src/main/java/MySpringBootRouterWarInitializer.java +++ /dev/null @@ -1,29 +0,0 @@ -## ------------------------------------------------------------------------ -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## ------------------------------------------------------------------------ -package ${package}; - -import org.apache.camel.spring.boot.FatJarRouter; -import org.apache.camel.spring.boot.FatWarInitializer; - -public class MySpringBootRouterWarInitializer extends FatWarInitializer { - - @Override - protected Class<? extends FatJarRouter> routerClass() { - return MySpringBootRouter.class; - } - -}
