Spring-boot / Maven simple “Hello World” application

The complete code for this application:

In this example I’ll try to show how to create a simple console application to print out the traditional “Hello World” message using spring-boot on a Maven project. I’ll try to keep it as simple as possible for now and I’ll most likely use this code as base for new posts.

Let’s start with the pom.xml file.

This is a simple console application so, for now, we only need “spring-boot-starter” as dependency.

You can also notice that I included a few plugins. The most important for now is the spring-boot-maven-plugin which will allow us to run the project with the “mvn spring-boot:run” Maven directive.

And now the main class:

That’s it.

The annotation @SpringBootApplication is a convenience annotation that implies a few others like @Configuration, @EnableAutoConfiguration and @ComponentScan. In more complex projects you most likely will declare each one individually to set a few parameters.

Now just execute the “mvn spring-boot:run” directive to run your application or “mvn package” to create a executable JAR file.

See ya!

You may also like...

3 Responses

  1. sdf says:

    Heya i’m for the first time here. I found this board and I find It truly useful & it helped me out much.
    I’m hoping to provide something again and aid others like you aided me.

  2. You actually make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complicated and extremely broad for me. I’m looking forward for your next post, I’ll try to get the hang of it!

  3. I think this is among the most significant information for me. And i’m glad reading your article. But wanna remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers

Leave a Reply

%d bloggers like this: