Spring Start Here

Book description

Quickly master the massive Spring ecosystem with this focused, hands-on guide that teaches you exactly what you need to know.

In Spring Start Here, you will learn how to:

  • Build web applications with Spring
  • Manage application objects with Spring context
  • Implement data persistence using data sources and transactions
  • Implement data exchange between applications using REST services
  • Utilize Spring Boot's convention-over-configuration approach
  • Write unit and integration tests for apps implemented with Spring
  • Minimize work when building any kind of app
  • Persisting data in a Spring application using the latest approach

Spring Start Here introduces you to Java development with Spring by concentrating on the core concepts you'll use in every application you build. You'll learn how to refactor an existing application to Spring, how to use Spring tools to make SQL database requests and REST calls, and how to secure your projects with Spring Security. There's always more to learn, and this book will make your next steps much easier.

About the Technology
For Java developers, Spring is the must-learn framework. This incredible development tool powers everything from small business ecommerce applications to enterprise-scale microservices. Mastering Spring is a long journey. Taking your first step is easy! Start here.

About the Book
Spring Start Here teaches Java developers how to build applications using Spring framework. Informative graphics, relevant examples, and author Laurenţiu Spilcă's clear and lively writing make it easy to pick up the skills you need. You'll discover how to plan, write, and test applications. And by concentrating on the most important features, this no-nonsense book gives you a firm foundation for exploring Spring's rich ecosystem.

What's Inside
  • Build web applications with Spring
  • Minimize repetition and manual work
  • Persisting data in a Spring application
  • HTTP and REST-based web services
  • Testing your Spring implementations


About the Reader
For readers with beginner to intermediate Java skills.

About the Author
Laurențiu Spilcă is a skilled Java and Spring developer and an experienced technology instructor.

Quotes
Takes you on a quick, entertaining, and pragmatic journey into the world of Spring.
- Christian Kreutzer-Beck, ARAG IT

A well-written and thorough introduction to Spring and Spring Boot.
- Jim Welch, Equifax Workforce Solutions

Fantastically pragmatic resource on Spring framework fundamentals.
- Andrew Oswald, Chariot Solutions

A great resource for individuals looking to bridge the gap from student to professional developer. A solid introduction to Spring.
- Daniel Carl, Oatey Co.

Publisher resources

View/Submit Errata

Table of contents

  1. Spring Start Here
  2. Copyright
  3. contents
  4. front matter
    1. foreword
    2. preface
    3. acknowledgments
    4. about this book
      1. Who should read this book
      2. How this book is organized: A roadmap
      3. About the code
      4. liveBook discussion forum
    5. about the author
    6. about the cover illustration
  5. Part 1 Fundamentals
  6. 1 Spring in the real world
    1. 1.1 Why should we use frameworks?
    2. 1.2 The Spring ecosystem
      1. 1.2.1 Discovering Spring Core: The foundation of Spring
      2. 1.2.2 Using Spring Data Access feature to implement the app’s persistence
      3. 1.2.3 The Spring MVC capabilities for developing web apps
      4. 1.2.4 The Spring testing feature
      5. 1.2.5 Projects from the Spring ecosystem
    3. 1.3 Spring in real-world scenarios
      1. 1.3.1 Using Spring in the development of a backend app
      2. 1.3.2 Using Spring in a automation test app
      3. 1.3.3 Using Spring for the development of a desktop app
      4. 1.3.4 Using Spring in mobile apps
    4. 1.4 When not to use frameworks
      1. 1.4.1 You need to have a small footprint
      2. 1.4.2 Security needs dictate custom code
      3. 1.4.3 Abundant existing customizations make a framework impractical
      4. 1.4.4 You won’t benefit from switching to a framework
    5. 1.5 What will you learn in this book
    6. Summary
  7. 2 The Spring context: Defining beans
    1. 2.1 Creating a Maven project
    2. 2.2 Adding new beans to the Spring context
      1. 2.2.1 Using the @Bean annotation to add beans into the Spring context
      2. 2.2.2 Using stereotype annotations to add beans to the Spring context
      3. 2.2.3 Programmatically adding beans to the Spring context
    3. Summary
  8. 3 The Spring context: Wiring beans
    1. 3.1 Implementing relationships among beans defined in the configuration file
      1. 3.1.1 Wiring the beans using a direct method call between the @Bean methods
      2. 3.1.2 Wiring the beans using the @Bean annotated method’s parameters
    2. 3.2 Using the @Autowired annotation to inject beans
      1. 3.2.1 Using @Autowired to inject the values through the class fields
      2. 3.2.2 Using @Autowired to inject the values through the constructor
      3. 3.2.3 Using dependency injection through the setter
    3. 3.3 Dealing with circular dependencies
    4. 3.4 Choosing from multiple beans in the Spring context
    5. Summary
  9. 4 The Spring context: Using abstractions
    1. 4.1 Using interfaces to define contracts
      1. 4.1.1 Using interfaces for decoupling implementations
      2. 4.1.2 The requirement of the scenario
      3. 4.1.3 Implementing the requirement without using a framework
    2. 4.2 Using dependency injection with abstractions
      1. 4.2.1 Deciding which objects should be part of the Spring context
      2. 4.2.2 Choosing what to auto-wire from multiple implementations of an abstraction
    3. 4.3 Focusing on object responsibilities with stereotype annotations
    4. Summary
  10. 5 The Spring context: Bean scopes and life cycle
    1. 5.1 Using the singleton bean scope
      1. 5.1.1 How singleton beans work
      2. 5.1.2 Singleton beans in real-world scenarios
      3. 5.1.3 Using eager and lazy instantiation
    2. 5.2 Using the prototype bean scope
      1. 5.2.1 How prototype beans work
      2. 5.2.2 Prototype beans in real-world scenarios
    3. Summary
  11. 6 Using aspects with Spring AOP
    1. 6.1 How aspects work in Spring
    2. 6.2 Implementing aspects with Spring AOP
      1. 6.2.1 Implementing a simple aspect
      2. 6.2.2 Altering the intercepted method’s parameters and the returned value
      3. 6.2.3 Intercepting annotated methods
      4. 6.2.4 Other advice annotations you can use
    3. 6.3 The aspect execution chain
    4. Summary
  12. Part 2 Implementation
  13. 7 Understanding Spring Boot and Spring MVC
    1. 7.1 What is a web app?
      1. 7.1.1 A general overview of a web app
      2. 7.1.2 Different fashions of implementing a web app with Spring
      3. 7.1.3 Using a servlet container in web app development
    2. 7.2 The magic of Spring Boot
      1. 7.2.1 Using a project initialization service to create a Spring Boot project
      2. 7.2.2 Using dependency starters to simplify the dependency management
      3. 7.2.3 Using autoconfiguration by convention based on dependencies
    3. 7.3 Implementing a web app with Spring MVC
    4. Summary
  14. 8 Implementing web apps with Spring Boot and Spring MVC
    1. 8.1 Implementing web apps with a dynamic view
      1. 8.1.1 Getting data on the HTTP request
      2. 8.1.2 Using request parameters to send data from client to server
      3. 8.1.3 Using path variables to send data from client to server
    2. 8.2 Using the GET and POST HTTP methods
    3. Summary
  15. 9 Using the Spring web scopes
    1. 9.1 Using the request scope in a Spring web app
    2. 9.2 Using the session scope in a Spring web app
    3. 9.3 Using the application scope in a Spring web app
    4. Summary
  16. 10 Implementing REST services
    1. 10.1 Using REST services to exchange data between apps
    2. 10.2 Implementing a REST endpoint
    3. 10.3 Managing the HTTP response
      1. 10.3.1 Sending objects as a response body
      2. 10.3.2 Setting the response status and headers
      3. 10.3.3 Managing exceptions at the endpoint level
    4. 10.4 Using a request body to get data from the client
    5. Summary
  17. 11 Consuming REST endpoints
    1. 11.1 Calling REST endpoints using Spring Cloud OpenFeign
    2. 11.2 Calling REST endpoints using RestTemplate
    3. 11.3 Calling REST endpoints using WebClient
    4. Summary
  18. 12 Using data sources in Spring apps
    1. 12.1 What a data source is
    2. 12.2 Using JdbcTemplate to work with persisted data
    3. 12.3 Customizing the configuration of the data source
      1. 12.3.1 Defining the data source in the application properties file
      2. 12.3.2 Using a custom DataSource bean
    4. Summary
  19. 13 Using transactions in Spring apps
    1. 13.1 Transactions
    2. 13.2 How transactions work in Spring
    3. 13.3 Using transactions in Spring apps
    4. Summary
  20. 14 Implementing data persistence with Spring Data
    1. 14.1 What Spring Data is
    2. 14.2 How Spring Data works
    3. 14.3 Using Spring Data JDBC
    4. Summary
  21. 15 Testing your Spring app
    1. 15.1 Writing correctly implemented tests
    2. 15.2 Implementing tests in Spring apps
      1. 15.2.1 Implementing unit tests
      2. 15.2.2 Implementing integration tests
    3. Summary
  22. Appendix A. Architectural approaches
    1. A.1 The monolithic approach
    2. A.2 Using a service-oriented architecture
      1. A.2.1 Complexity caused by communication among services
      2. A.2.2 Complexity added to the security of the system
      3. A.2.3 Complexity added for the data persistence
      4. A.2.4 Complexity added in the deployment of the system
    3. A.3 From microservices to serverless
    4. A.4 Further reading
  23. Appendix B. Using XML for the context configuration
  24. Appendix C. A quick introduction to HTTP
    1. C.1 What is HTTP?
    2. C.2 The HTTP request as a language between client and server
    3. C.3 The HTTP response: The way the server responds
    4. C.4 The HTTP session
  25. Appendix D. Using JSON formatting
  26. Appendix E. Installing MySQL and creating a database
    1. Step 1: Install a DBMS on your local system
    2. Step 2: Install a client application for your DBMS
    3. Step 3: Connecting to the local DBMS
    4. Step 4: Add a new database
  27. Appendix F. Recommended tools
  28. Appendix G. Recommended learning materials for further study
  29. index

Product information

  • Title: Spring Start Here
  • Author(s): Laurentiu Spilca
  • Release date: October 2021
  • Publisher(s): Manning Publications
  • ISBN: 9781617298691