Spring-Boot initial setup.
Create a simple maven project in your Eclipse. Here is the pom.xml reference:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.java2novice.springboot</groupId>
<artifactId>spring-boot-tutorials</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<!-- Specify java version -->
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
|
The above pom.xml includes the minimum required declarations to run the spring-boot application. Make sure that
you are using java 1.8 version. We will get more details on the details included in the pom.xml in the coming pages.
Once you update your pom.xml, dont forget to run "Update Project" under Maven option on your project. It will
automatically updates your project settings according to the specifications under pom.xml file.
Now, lets create a java class as shown below and annotate it with @SpringBootApplication annotation.
Thats it. Your spring boot application is ready.
package com.java2novice.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootWebApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootWebApplication.class, args);
}
}
|
Run the above class to initialize spring boot application. It deployes application into the tomcat and starts
the tomcat.
Here is the example image to show you how to run the spring boot application:
Run Spring-boot Application

Here is the output. Note that the tomcat is started and running on port 8080. We will get more details in the next pages.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.1.RELEASE)
2017-10-19 11:19:48.923 INFO 93490 --- [ main] c.j.s.starter.SpringBootWebApplication : Starting SpringBootWebApplication on Nattu-2.local with PID 93490 (/Users/java2novice/SiteWorkspace/spring-boot-tutorials/target/classes started by java2novice in /Users/java2novice/SiteWorkspace/spring-boot-tutorials)
2017-10-19 11:19:48.925 INFO 93490 --- [ main] c.j.s.starter.SpringBootWebApplication : No active profile set, falling back to default profiles: default
2017-10-19 11:19:48.968 INFO 93490 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5427c60c: startup date [Thu Oct 19 11:19:48 IST 2017]; root of context hierarchy
2017-10-19 11:19:49.499 INFO 93490 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-19 11:19:49.549 INFO 93490 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-19 11:19:49.783 INFO 93490 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-10-19 11:19:49.792 INFO 93490 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-10-19 11:19:49.793 INFO 93490 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-10-19 11:19:49.870 INFO 93490 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-10-19 11:19:49.870 INFO 93490 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 904 ms
2017-10-19 11:19:49.970 INFO 93490 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-10-19 11:19:49.973 INFO 93490 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-10-19 11:19:49.973 INFO 93490 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-10-19 11:19:49.973 INFO 93490 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-10-19 11:19:49.973 INFO 93490 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-10-19 11:19:50.211 INFO 93490 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5427c60c: startup date [Thu Oct 19 11:19:48 IST 2017]; root of context hierarchy
2017-10-19 11:19:50.277 INFO 93490 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-10-19 11:19:50.278 INFO 93490 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-10-19 11:19:50.302 INFO 93490 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-19 11:19:50.302 INFO 93490 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-19 11:19:50.333 INFO 93490 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-19 11:19:50.450 INFO 93490 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-10-19 11:19:50.498 INFO 93490 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-10-19 11:19:50.503 INFO 93490 --- [ main] c.j.s.starter.SpringBootWebApplication : Started SpringBootWebApplication in 2.121 seconds (JVM running for 2.411)
|
|