Spring Boot Hello World Application

Spring Boot Hello World Application

Spring Boot is new project which gives solution to create convention over configuration stand alone application. Using this you could create production grade application deploy and just run. To take flavor of this please see how we create Hello World Application of Spring Boot:

  • Create maven project name: SpringBootTest
  • Final project structure:

Spring Boot is new project which gives solution to create convention over configuration stand alone

 

  • pom.xml:

  • dispatcher-servlet.xml:

  • index.jsp:

  • SpringBootController.java:

  • Application.java:

  • For this demo we are running in eclipse with tomcat sever and if you are not sure how to configure run tomcat in eclipse please follow this tutorial. To run: right click project –> Run As –> Run on server there you will see below output:

Spring Boot Hello World Application

  • Type below URL in browser you will see below output:

Spring Boot Hello World Application

  • Now send HTTP request to controller as RESTFul you will get below JSON response:

2014-10-28 15_20_43-localhost_8080_SpringBootTest_springboot

Now run stand alone application: 

  • Right click Application.java –> Run As –> Java Application you will below output:

Spring Boot Hello World Application

  • That’s it for more information about Spring Boot please read this tutorial

download Download Project: SpringBootTest

One thought on “Spring Boot Hello World Application

  1. Hi sir,

    First I need to say big thanks to you,for sharing valuable information in the form of this site.Many more technologies information is available for beginners as well as for advanced learners. Related to spring boot example , i am downloaded your code .when it is running as web server it is working fine.After server stopped tried as standalone .But in case running as standalone, no errors is coming in console ,when i invoking url(http://localhost:8080/SpringBootTest/springboot) in the browser it not getting the desired output. Can you please suggest me what is the way to run the example without starting server using as Run as server.

    My console Output:

    . ____ _ __ _ _
    /\\ / ___’_ __ _ _(_)_ __ __ _ \ \ \ \
    ( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ \
    \\/ ___)| |_)| | | | | || (_| | ) ) ) )
    ‘ |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot :: (v1.1.8.RELEASE)

    2014-12-17 13:03:42.912 INFO 2764 — [ main] com.javahonk.Application : Starting Application on SON16024 with PID 2764 (C:\Users\ramanujam.as\Downloads\SpringBootTest\SpringBootTest\target\classes started by ramanujam.as in C:\Users\ramanujam.as\Downloads\SpringBootTest\SpringBootTest)
    2014-12-17 13:03:42.953 INFO 2764 — [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@73fa5e49: startup date [Wed Dec 17 13:03:42 IST 2014]; root of context hierarchy
    2014-12-17 13:03:44.520 INFO 2764 — [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
    2014-12-17 13:03:44.548 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Registering beans for JMX exposure on startup
    2014-12-17 13:03:44.825 INFO 2764 — [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
    2014-12-17 13:03:44.827 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘requestMappingEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=requestMappingEndpoint]
    2014-12-17 13:03:44.849 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘environmentEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=environmentEndpoint]
    2014-12-17 13:03:44.857 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘healthEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=healthEndpoint]
    2014-12-17 13:03:44.863 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘beansEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=beansEndpoint]
    2014-12-17 13:03:44.868 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘infoEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=infoEndpoint]
    2014-12-17 13:03:44.874 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘metricsEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=metricsEndpoint]
    2014-12-17 13:03:44.880 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘traceEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=traceEndpoint]
    2014-12-17 13:03:44.885 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘dumpEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=dumpEndpoint]
    2014-12-17 13:03:44.894 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘autoConfigurationAuditEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=autoConfigurationAuditEndpoint]
    2014-12-17 13:03:44.899 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘shutdownEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=shutdownEndpoint]
    2014-12-17 13:03:44.907 INFO 2764 — [ main] o.s.b.a.e.jmx.EndpointMBeanExporter : Located managed bean ‘configurationPropertiesReportEndpoint’: registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=configurationPropertiesReportEndpoint]
    2014-12-17 13:03:44.913 INFO 2764 — [ main] com.javahonk.Application : Started Application in 2.39 seconds (JVM running for 2.671)
    Let’s inspect the beans provided by Spring Boot:
    application
    auditEventRepository
    auditListener
    autoConfigurationAuditEndpoint
    beansEndpoint
    configurationPropertiesReportEndpoint
    counterService
    dumpEndpoint
    endpointMBeanExporter
    endpoints.jmx.CONFIGURATION_PROPERTIES
    environmentEndpoint
    gaugeService
    healthAggregator
    healthEndpoint
    http.mappers.CONFIGURATION_PROPERTIES
    infoEndpoint
    jacksonObjectMapper
    managementServerProperties
    mappingJackson2HttpMessageConverter
    mbeanExporter
    mbeanServer
    messageConverters
    messageSource
    metricRepository
    metricsEndpoint
    objectNamingStrategy
    org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration$AuditEventRepositoryConfiguration
    org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$InfoPropertiesConfiguration
    org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$RequestMappingEndpointConfiguration
    org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration
    org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration$MetricRepositoryConfiguration
    org.springframework.boot.actuate.autoconfigure.TraceRepositoryAutoConfiguration
    org.springframework.boot.autoconfigure.AutoConfigurationPackages
    org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration
    org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
    org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
    org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperAutoConfiguration
    org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration
    org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration$Empty
    org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
    org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$ObjectMappers
    org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor
    org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store
    org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor
    org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor
    org.springframework.context.annotation.MBeanExportConfiguration
    org.springframework.context.annotation.internalAutowiredAnnotationProcessor
    org.springframework.context.annotation.internalCommonAnnotationProcessor
    org.springframework.context.annotation.internalConfigurationAnnotationProcessor
    org.springframework.context.annotation.internalRequiredAnnotationProcessor
    propertySourcesPlaceholderConfigurer
    requestMappingEndpoint
    shutdownEndpoint
    springBootController
    statusHealthIndicator
    traceEndpoint
    traceRepository
    2014-12-17 13:03:44.915 INFO 2764 — [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@73fa5e49: startup date [Wed Dec 17 13:03:42 IST 2014]; root of context hierarchy
    2014-12-17 13:03:44.916 INFO 2764 — [ Thread-1] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
    2014-12-17 13:03:44.918 INFO 2764 — [ Thread-1] o.s.b.a.e.jmx.EndpointMBeanExporter : Unregistering JMX-exposed beans on shutdown
    2014-12-17 13:03:44.919 INFO 2764 — [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

    Thanks in Advance
    Ramanujam

Leave a Reply

Your email address will not be published. Required fields are marked *