Posts

Showing posts from February, 2014

Running a spring boot application with maven

On the last 2 part tutorial that I published recently on Spring boot :Spring boot and spring data (part 1) and Spring boot and spring data (part 2) I said that when using pure maven (not the groovy approach) you needed to either package the project and then run the JAR manually or use the maven mojo exec plugin (which I preferred)But as often after playing a bit more with it I realized that there is an even simpler solution and that is using the run goal of the spring-boot maven pluginSo you can simply run your spring-boot project by executing the following goal on your console/IDE mvn spring-boot:run

Spring boot and spring data jpa tutorial - A sample application using spring 4.0 spring boot and JPA (part 2/2)

This is the second part of the Spring boot and spring data jpa tutorial - A sample application using spring 4.0 spring boot and JPA At the end of the tutorial I promised you that we will be removing one of the steps when running the application, that is merge the package and run in a maven command and make him do the work 5.- Making maven run the JAR directlyWe're going to make maven run the runnable JAR for us after it has been packaged, for this purpose we're going to use one of org.codehaus.mojo maven plugins .... org.springframework.bootspring-boot-maven-pluginorg.codehaus.mojoexec-maven-plugin1.2.1com.ufasoli.tutorials.spring.boot.HelloWorldApp ... So what's happening here ? : By adding the exec plugin to the build section of our pom.xml and providing a mainClass when we run the appropriate maven goals the application will be packaged and run directly from maven You can try this by running : mvn clean package exec:java By running this on your console the appl…

Spring boot and spring data jpa tutorial - A sample application using spring 4.0 spring boot and JPA (part 1/2)

Spring boot is a strongly opinionated framework / generator based on the principle of convention over configuration, which according to the website: Spring Boot makes it easy to create Spring-powered, production-grade applications and services with absolute minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need Basically by using a few annotations and minimum boilerplate code the framework/generator will configure all the necessary beans and contexts based on a set of conventions.Spring boot has a few modules that depending on your needs can speed-up development such as : spring data jpa spring data mongodb spring webspring actuator...Personally I find that when using the spring stack this tool is pretty awesome!!When using this tool you must know that there are actually 2 ways to use spring boot : Using the cli (and by extension groovy)Using good old maven and the spring-boot plugins In this tutorial we …