Spring Boot

De My Limbic Wiki
Aller à : navigation, rechercher

Scope

  • Big environment wich is use to help us develop applications.
  • if Spring MVC need configuration ? Spring Boot does it.
  • Other jars needed to develop web applications ? there are starters allowing to easily build application
  • Monitoring, and developer friendly tools
  • Good integration with embeded servers: No need to develop a WAR file always, it is possible to develop a JAR and directly run it cause the Tomcat server is directly inside the JAR.

Comparaison with Spring Boot and Spring https://www.springboottutorial.com/spring-boot-vs-spring-mvc-vs-spring

What's new

Come with:

  • Autoconfiguration
    • Previously (Spring_MVC) Bean, Resources, Servlet, View Resolver configuration
  • Starters (Spring boot starter web ...)
    • Bring all the dependencis required to build web applications

Mock - Dependency Injection

 @Component
 public class WelcomeService {
   //Bla Bla Bla
 }
 
 @RestController
 public class WelcomeController {
 
   @Autowired
   private WelcomeService service;
 
   @RequestMapping("/welcome")
   public String welcome() {
     return service.retrieveWelcomeMessage();
   }
 }

Spring Boot Starter Project Options

Dependencies to use in pom.xml available to start faster a spring boot project.

spring-boot-starter-*:

  • -web-services - SOAP Web Services
  • -web - Web & RESTful applications
  • -test - Unit testing and Integration Testing
  • -jdbc - Traditional JDBC
  • -hateoas - Add HATEOAS features to your services
  • -security - Authentication and Authorization using Spring Security
  • -data-jpa - Spring Data JPA with Hibernate
  • -cache - Enabling Spring Framework’s caching support
  • -data-rest - Expose Simple REST Services using Spring Data REST

Technical Stuff

spring-boot-starter-*:

  • -actuator - To use advanced features like monitoring & tracing to your application out of the box
  • -undertow, -jetty, -tomcat To pick your specific choice of Embedded Servlet Container
  • -logging - For Logging using logback
  • -log4j2 - Logging using Log4j2