Spring Boot: Difference between revisions

From My Limbic Wiki
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=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
Comparaison with Spring Boot and Spring
https://www.springboottutorial.com/spring-boot-vs-spring-mvc-vs-spring
https://www.springboottutorial.com/spring-boot-vs-spring-mvc-vs-spring
Line 10: Line 17:


=Mock - Dependency Injection=
=Mock - Dependency Injection=
  '''@Component'''
<source lang="java">
  @Component
  public class WelcomeService {
  public class WelcomeService {
   //Bla Bla Bla
   //Bla Bla Bla
Line 18: Line 26:
  public class WelcomeController {
  public class WelcomeController {
   
   
   '''@Autowired'''
   @Autowired
   private WelcomeService service;
   private WelcomeService service;
   
   
Line 26: Line 34:
   }
   }
  }
  }
</source>


=Spring Boot Starter Project Options=
=Spring Boot Starter Project Options=

Latest revision as of 19:59, 23 September 2019

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

<source lang="java">

@Component
public class WelcomeService {
  //Bla Bla Bla
}

@RestController
public class WelcomeController {

  @Autowired
  private WelcomeService service;

  @RequestMapping("/welcome")
  public String welcome() {
    return service.retrieveWelcomeMessage();
  }
}

</source>

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