Spring Framework och Spring Boot

Det finns inget Java ramverk som på ett mer genomgripande sätt förändrat hur vi designar och implementerar affärs-applikation under de senaste 15 åren som Spring Framework. Via Spring Boot är det lekande lätt att bygga själv-konfigurerande webb-applikationer. Denna kurs lär dig allt du behöver veta för att bli produktiv i ett spring projekt direkt efter avslutad kurs.

Spring Framework och Spring Boot
4 dagar
Advanced
Javautvecklare
Rutinerad i Java programmering
  • Java JDK 11+
  • SDKMAN
  • Maven || Gradle
  • JetBrains IntelliJ IDEA || MS Visual Code
Här ser du vilka kursdatum som är tillgängliga. Klicka på en av datumknapparna för att anmäla dig till ett kurstillfälle. På kursen pratar läraren svenska, medan vårt kursmaterial alltid är författat på engelska.

Du sitter bekvämt framför datorn och deltar i kursen via internet. Vi använder programvaran Zoom för alla våra fjärrkurser.

I priset ingår kursmaterial som PDF.

Pris: 20 000 kr + MOMS/VAT (25%)

Du sitter bekvämt i ett av våra klassrum, vilka finns centralt placerade i Stockholms innerstad (Östermalmstorg).

I priset ingår tryckt kursmaterial (och som PDF), samt kaffe/te med smörgås på förmiddagen och kaffe/te med bulle på eftermiddagen.

Pris: 25 000 kr + MOMS/VAT (25%)

Om ni är tre eller fler personer från samma företags, kan ni beställa en företagsanpassad kurs. Då håller vi kursen på ett datum som passar er. Antingen på plats i era lokaler eller som en fjärrkurs. Vi kan även mixa fjärr- och klassrumskurs, om några av er önskar delta på distans medan resten föredrar att ses på plats.

Företagsanpassad Kurs

Här är ett sammandrag av vad du får lära dig på kursen.

  • Learn how wire together spring beans using both XML and Java annotations
  • Using Spring Boot
  • Implementing classic web apps
  • Implementing hybrid AJAX based web apps
  • Implementing SPA web apps
  • Implementing REST controllers
  • Accessing databases using both JDBC and JPA
  • Configuring Spring Security

Background & History

  • Rod Johnson
  • The fallacy of EJB
  • Why Spring was created
  • Properties of Spring
  • Spring configuration forms
  • The evolution and success of Spring
  • When Spring started to crumble on its own weight
  • The inception of Spring Boot
  • Properties of Spring Boot
  • Overview of Spring projects

JVM Fundamentals

  • Class-Path
  • JAR files
  • Executable JAR file
  • WAR files
  • How the JVM load classes
  • ClassLoader & URLClassLoader
  • Static vs. Thread-local variables

Build Tools

  • Maven & Gradle
  • Java build-tool evolution
  • Application builds
  • Common project layout
  • 3rd party libraries
  • Dependencies
  • Transitive dependencies
  • Using mvnrepository.com
  • Artifact repositories
  • Brief about Maven
  • Brief about Gradle
  • Using SDKMAN
  • Installation of Maven and Gradle

Simple Project One

Presentation of a small non-Spring project, that you will gradually adapt to Spring.

Spring Concepts

  • DI - Dependency Injection
  • IoC - Inversion of Control
  • Call-back methods
  • Constructor injection
  • Method injection
  • Field injection
  • JavaBean vs. SpringBean
  • XML beans
  • @nnotation beans
  • Scopes
  • Life-cycle call-backs
  • Principles of AOP

XML Configuration

The classic way of wire an application together.

  • Why learn XML configuration
  • Basic XML bean syntax
  • Setter injection
  • Constructor injection
  • Bean references
  • How to load XML bean files
  • Bean scopes in XML
  • Configuring factory methods
  • Life-cycle call-backs in XML
  • Using auto-wiring in XML
  • Collection property types

Java Configuration

The better way of wire an application together.

  • What is Java configuration of a Spring app
  • Writing a @Configuration class with @Bean methods
  • Application context
  • Context registration
  • Injecting bean dependencies
  • Scopes
  • Initialization method
  • Destruction method
  • Life-cycle call-backs

@nnotation Configuration

The modern way of wire an application together.

  • Writing a @Component class and how it relates to @Configuration and @Bean
  • Class-path scanning
  • Using the scan() method
  • Using @ComponentScan
  • Using @Autowired
  • Constructor injection
  • Using a @Qualifier to select a bean by name
  • Spring stereotypes

Brief about JDBC

  • History
  • Drivers
  • JDBC URL
  • Connection
  • Statements
  • Prepared statements
  • Queries
  • Iterating over a result-set

Database Access via Spring JDBC

Using JDBC in Spring with JdbcTemplate and friends.

  • Spring JDBC module
  • Class JdbcTemplate
  • Configuring a DataSource
  • DriverManagerDataSource
  • Embedded database
  • H2 memory db
  • H2 file db
  • H2 server db
  • MySQL / PostgreSQL data sources
  • Query for a single value
  • Query for a multiple values
  • Query for a domain object
  • Handle not-found
  • Query for a Stream
  • Named query parameters
  • Usage of NamedParameterJdbcTemplate
  • Retrieve an auto-generated primary-key

Spring Boot

Presentation of Spring Boot and its relation to Spring Framework. Discussions of concepts such as starter dependencies and auto-configuration.

  • Why Spring Boot was created
  • What is Spring Boot more precisely
  • Started dependencies
  • Auto-configuration
  • Spring Initializer
  • Generating an executable JAR
  • Generating a WAR file for deployment

Using Lombok

  • What is Lombok
  • Generate getters & setters
  • Generate constructors
  • Generate toString() method
  • Generate equals() & hashCode() methods
  • Using @Data to bundle them all
  • Using @Value to create an immutable data-class

Configuration Properties

Different ways to provide configuration properties.

  • What is a configuration property
  • Application *.properties file
  • Standard Spring properties
  • Inject property to field
  • Inject group of properties to a bean
  • Inject all app properties
  • Standard type conversions
  • Using YaML (*.yml)
  • Override on the command-line
  • Override by an environment variable
  • Using application profiles
  • Profile-dependent property files

Database access via JPA

How to use Spring JPA and auto-configuration

  • What is JPA
  • What is ORM
  • What is JDO
  • Spring Data project
  • Spring Data JPA
  • Starter dependencies
  • Configure a data-source
  • JNDI data-source
  • Connection pool
  • Hikari CP
  • Entity class
  • JPA annotations
  • JPA repository interface
  • Auto-generated CRUD methods
  • Database initialization
  • Writing query auto-methods
  • Using the @Query annotation

HTTP Concepts

Brief about HTTP and web concepts in order to relate and put into context of the Spring Web Apps chapters of this course.

  • HTTP Request / response
  • HTTP operations (methods)
  • URI / path
  • MIME types
  • Response status codes
  • Cookies
  • Java servlet
  • JSP
  • MVC
  • AJAX
  • XMLHttpRequest
  • The new fetch API
  • REST web services
  • REST operations
  • Web app architectures
  • The classic multi-page app
  • The hybrid multi-page app
  • The modern single-page app
  • Deployments
  • Assets server vs API server
  • What is a CDN
  • Understanding CORS

Building a classic multi-page web app

Using Spring MVC with HTML views.

  • Creating a Spring Boot project
  • The Spring Web MVC architecture
  • Starter package
  • Understanding controllers and views
  • GET actions
  • POST actions
  • View resolution and mapping
  • Template engines
  • Using Mustache
  • Assets files
  • URI path composition
  • Path variables
  • Redirection
  • Query parameters
  • Form data
  • Form data bean

Building an AJAX hybrid web app

Using Spring MVC with AJAX powered HTML views.

  • Creating a Spring Boot project
  • Changes of controllers
  • Changes of view pages
  • Controller-less views
  • Sample REST CRUD controller
  • JavaScript DAO service

Building a single-page web app

Using Spring REST as a microservice.

  • Creating a Spring Boot project
  • Changes of controllers and views
  • Run-time deployment of an SPA client
  • External SPA client
  • Configuring CORS
  • Internal SPA client
  • Spring configuration for an internal SPA client
  • SPA controller

Authentication & Authorization

Brief about concepts and terminology

  • What is authentication
  • What is authorization
  • Principal & credentials
  • Permissions, roles and authority
  • Basic authentication
  • Cookie-based authentication
  • Token-based authentication
  • JWT
  • OATH
  • Spring Security project
  • Spring Security architecture

Spring Security for Classic Web-Apps

  • Step-wise adding/configuring security
  • Default settings for Spring Boot
  • UserDetails interface
  • UserDetailsService interface
  • Password encoding
  • Understing Basic authentication
  • Configuring form-based authentication
  • Configuring role-based authorization
  • Obtaining the logged-in user
  • In-memory user-store
  • JDBC user-store
  • Understanding CSRF and how it is prevented in Spring

Spring Security for Modern Web-Apps

  • Understanding JSON web token (JWT)
  • Configuration for a REST back-end and SPA front-end
  • Sing-on using a Java JWT library
  • Implementing a JWT filter

Deployment

Best practices for deploying Spring apps.

  • Deployment options
  • Generating an executable JAR as a microservice
  • Generating a WAR for deployment to a servlet container
  • Working with configuration profiles
  • Brief about database schema migration tools