Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf for (XPages) developers

336 views

Published on

The world of (XPages) developer is moving fast. Customers rethinking platforms and solutions. Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". In combination with Thymeleaf can it be good alternative for your XPages applications.
In this session I give an introduction of Spring Boot and Thymeleaf and how to get started. I will show the differences and similarities between Spring Boot in combination with Thymeleaf and XPages.
I will explain the challenges I faced when moving an application.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf for (XPages) developers

  1. 1. 2018 Spring forward: an introduction to Spring boot and Thymeleaf for (XPages) developers Frank van der Linden Full stack Developer elstar IT
  2. 2. Thanks to our 2018 Sponsors INFORMATION SOLUTIONS REDTABLE
  3. 3. Me • Freelance Full stack developer • Owner of elstar IT • Curious of new technology • IBM Champion 2013, 2014, 2017 and 2018 3
  4. 4. Disclaimer 4 Session is NOT about Domino and XPages
  5. 5. How to proceed • What is Spring boot and Thymeleaf • Similarities and differences • Runs everywhere • How to start • Syntax • Security • New possibilities 5
  6. 6. What is Spring boot and Thymeleaf
  7. 7. Spring Ecosystem 7
  8. 8. Spring boot • Open source, Pivotal is coordinating. • Spring boot creates Spring (Java) based applications • Embedded Tomcat makes it ‘just’ run everywhere • Auto configure as much as possible • Built in metrics and health checks • Easy to configure with YAML or property file • Very good documentation and code examples • Fast creation of REST api’s 8
  9. 9. Thymeleaf • Is a template engine • Based on Java and HTML5 • Very strict, or template will break • Full Spring framework support • Extensible with dialects • Full (and extensible) internationalisation support. • Reusable fragments, like of Custom Controls • Extensive documentation 9
  10. 10. Similarities and differences
  11. 11. 11 XPages Spring Boot/Thymeleaf Configure Faces-config @Autowired Endpoints Need work or SmartNSF very strong support Security Built-in Need Spring Security Add-ons Lots of 3rd party add-on Thanks to OpenNTF Lots of 3rd party add-on Deployment Runs on Domino Runs everwhere Build Pain of the Domino Designer Maven/Gradle build out-of-the box IDE DDE (Windows) for OSGi plugins almost every IDE Almost every IDE, like Netbeans, Eclipse, IntelliJ and more (Windows, Linux, MacOS)
  12. 12. Runs everywhere
  13. 13. Runs everywhere • With Embedded Tomcat as default the jar ‘just run’ • More choices of embedded web server, in the future also OpenLiberty • Will run on Docker • Will run on Cloud Foundry, like IBM Cloud or Pivotal on Azure • Tomcat can by excluding to run it on Websphere Application Server, Tomcat or WildFly (a.k.a JBoss) • Even on Domino as OSGi plugin, http://hasselba.ch/blog/?p=2589 13
  14. 14. How to start
  15. 15. How to start • Install Gradle or Maven • Move over to start.spring.io • Or use the Starter in IntelliJ • Fill all the fields and select the required projects (full version) • Generate project • Download zip, unzip and add to Git repository. • Open project in favourite IDE, run ‘mvn clean install’ • Start coding 15
  16. 16. Wizard in IntelliJ
  17. 17. Spring boot setup 17 minimal YAML file
  18. 18. Thymeleaf setup 18 add to pom.xml
  19. 19. How it works together 19
  20. 20. Syntax
  21. 21. Spring boot syntax 21 endpoint to return an object as JSON endpoint to return a thymeleaf template
  22. 22. Component scan • Component scan will scan all the packages for @Service, @Controller, @Repository and more @Component(s) • @Autowired will glue everything together 22
  23. 23. Thymeleaf syntax • Include the th namespace to the page • Every html element attribute has a th:…. Equivalent. • Variable Expressions: ${...} • Selection Variable Expressions: *{...} • Message Expressions: #{...} • Link URL Expressions: @{...} 23
  24. 24. Namespace 24 <html lang="en" xmlns:th="http://www.thymeleaf.org">
  25. 25. Thymeleaf attributes 25
  26. 26. Variable Expressions 26
  27. 27. Selection Variable Expressions 27
  28. 28. Message Expressions 28
  29. 29. Link URL Expressions 29 resource links links in on a page
  30. 30. Global objects 30
  31. 31. Fragments (1) 31
  32. 32. Fragments (2) 32 fragment code use it multiple times
  33. 33. Attachments • Forget the UploadedFile provided by IBM, learn MultipartFile • MultipartFile has lots of similarities with UploadedFile, but easier to use. Less code to achieve the same 33
  34. 34. Security
  35. 35. Spring Security • Framework for Authentication and Authorisation • Prevention of clickjacking, CORS, cross site request forgery • Integrates with Spring Boot and Thymeleaf • Customisable to the bone • Support for Basic Authentication, SAML2, oAuth and more. 35
  36. 36. Configuration 36 CORS prevention
  37. 37. Spring security in Thymeleaf 37 add to pom.xml add namespace
  38. 38. New possibilities
  39. 39. Lombok • Forget Getters and Setters • Forget toString, hashCode and equals • One @Annotations rules the all (@Data or @Getter and @Setter) • Add logging by @annotations (@Log4j2 or @Slf4j) 39
  40. 40. Lombok 40 add to pom.xml add @Data using the build in logging
  41. 41. Swagger • Part of Open API Specification, since v3 • Documentation of API’s • Playground for testing • Add annotation to generate the documentation dynamically 41
  42. 42. Swagger 42 add to pom.xml add a configuration add annotation to endpoint
  43. 43. Jenkins • With Jenkins you can build automatically the application • …But also do quality control, do load tests and even deploy. • JenkinsFile should be in the root of the GIT Repository • Groovy is the language for JenkinsFile 43
  44. 44. Jenkins file 44
  45. 45. Spring Forward Starter 45 https://bitbucket.org/flinden68/spring-forward-starter
  46. 46. Questions
  47. 47. Reach out to me • @flinden68 • http://www.elstarit.nl • flinden68@elstarit.nl • https://nl.linkedin.com/in/flinden68 47
  48. 48. Resources • Spring Initializr • http://start.spring.io/ • Thymeleaf documentation • http://www.thymeleaf.org/ • Spring Boot • https://projects.spring.io/spring-boot/ • Lombok • https://projectlombok.org/ • Jenkins • https://jenkins.io/ 48
  49. 49. Resources • Swagger • http://swagger.io • Thymeleaf documentation • http://www.thymeleaf.org/ • Maven • https://maven.apache.org/ • Gradle • https://gradle.org/ • Spring Forward Starter • https://bitbucket.org/flinden68/spring-forward-starter 49
  50. 50. Thanks to our 2018 Sponsors INFORMATION SOLUTIONS REDTABLE

×