The Java Spring Tutorial: Learn Java's Popular Web Framework

Learn the hottest, most in-demand Java web framework, including web programming with Spring MVC and Hibernate.
134 reviews
TAUGHT BY
  • John Purcell Software Development Trainer

    After working as a software developer and contractor for over 14 years for a whole bunch of companies including CSC, Proquest, SPSS and AT&T in the UK and Netherlands, I decided to work full-time as a private software trainer. I now live in the beautiful city of Budapest, Hungary, from where I run the website Cave of Programming.

WHAT'S INSIDE
  • Lifetime access to 174 lectures
  • 27+ hours of high quality content
  • A community of 9200+ students learning together!
  • 670+ discussions
SHARE

The Java Spring Tutorial: Learn Java's Popular Web Framework

Learn the hottest, most in-demand Java web framework, including web programming with Spring MVC and Hibernate.
134 reviews

HOW UDEMY WORKS?

Discover courses made by experts from around the world.

Take your courses with you and learn anytime, anywhere.

Learn and practice real-world skills and achieve your goals.

COURSE DESCRIPTION

An introduction to the widely-used Java Spring framework. Discover how to wire together your Java objects using Spring and dependency injection. You'll learn how to set up your system for Spring development, how to use Maven, and how to work with databases using Spring and Hibernate and how to create web applications with Spring MVC. We'll also look at managing user accounts with Spring Security,JDBC, working with web forms, Apache tiles for building modular web pages, aspect-oriented programming (AOP) and using Log4J and JUnit.

    • Fair knowledge of the Java programming language
    • Knowledge of HTML, servlets and JSPs is recommended for the web section of this tutorial
    • Some acquaintance with XML is helpful
    • Knowledge of SQL and databases is helpful for the database-related parts of this tutorial
    • Over 174 lectures and 28 hours of content!
    • Understand the fundamentals of the Java Spring framework
    • Learn how to develop web and database applications with Spring
    • Understand the basics of Hibernate for SQL-free database connectivity
    • Java developers
    • Anyone with some fluency in Java and an interest in web or database programming

THE UDEMY GUARANTEE

30 day money back guarantee
Lifetime access
Available on Desktop, iOs and Android
Certificate of completion

CURRICULUM

  • SECTION 1:
    Getting Started
  • 1
    What is Spring?
    06:30
    In this video we'll start by discussing what you can use Spring for and what Spring actually is.
  • 2
    Setting Up Your System
    15:54
    How to set up your system for Spring development, installing Java, Eclipse EE, Maven, the m2e Maven Eclipse plug, the Spring IDE Eclipse plugin, and optionally Tomcat if you want to get into web development.
  • 3
    Introducing Maven
    13:31
    In this video we'll take a look at Maven; what it is, basic usage, and how to create a basic Maven project. We'll only need a basic knowledge of Maven to do everything we want to do later on with Spring, in fact. This tutorial assumes you've installed the Maven Integration for Eclipse plugin as described in the previous tutorial, and that you have a connection to the Internet.
  • 4
    Using Maven on the Command Line
    08:45
    A tutorial on creating Maven projects from the command line. This is an optional video in this course; we won't actually need to use Maven from the command line, but seeing what's possible using “pure” Maven will help you to understand Maven, and for that reason I've created this tutorial.
  • 5
    Spring "Hello World"
    21:10
    Creating a simple “hello world” project in Spring. Yes, finally it's time to create an actual Spring project, now that we've got our system set up.
  • 6
    Class Path Contexts
    05:12
    We can load Spring XML files from anywhere on the classpath; we'll see how to do it here.
  • SECTION 2:
    Basic Bean Configuration
  • 7
    Constructor Arguments
    08:16
    In this tutorial we'll take a look at how we can supply arguments to the constructors of our Spring beans via XML.
  • 8
    Setting Bean Properties
    07:16
    Of course it's possible to set properties of beans in Spring from XML; that is, we can invoke set methods of our objects and pass values to them which we code into the XML.
  • 9
    Dependency Injection
    11:39
    Dependency Injection is one of the buzzwords for which Spring is famous. It sounds ferocious, but it isn't at all complicated. Here we'll take a look at how we can inject a Spring bean with another bean, allowing you to configure your beans with whatever services or facilities take your fancy – provided you've got the functionality you need in another bean somewhere, of course.
  • 10
    Bean Scope
    04:25
    Beans have a scope; for our purposes here, the choice we have is between reusing our one and only bean or creating new beans to order.
  • 11
    Init and Destroy Methods
    08:47
    Beans in Spring have a distinct lifecycle, and we can make code run when beans are created or destroyed. Finally a reliable “destructor” in Java! Well, sort of.
  • 12
    Factory Beans and Methods
    13:03
    Sometimes you want to create objects via a factory method or class rather than via a public constructor. Spring makes it easy to do this through your application contexts
  • 13
    The P Namespace
    05:30
    Yes, it sounds like something terrible from theoretical physics, but actually it's a simple way of setting bean properties with minimal typing
  • 14
    Setting List Properties
    05:48
    If you need to set a bean property that's actually a list or set of stuff from XML, you can do this too quite easily.
  • 15
    Lists of Beans
    05:21
    What if you need to pass a bean a whole list of other beans? Once again it's quite simple.
  • 16
    Inner Beans
    03:51
    Sometimes you want to define a bean solely for the purpose of passing it to another bean, and you never want to refer to it in your XML again. In that case, maybe you need an inner bean.
  • 17
    Property Maps
    04:05
    There's a class in Java called “Properties”, which is basically a kind of Map. In Spring, whenever a bean property expects to be passed a Map, and the keys and values are both Strings, we can use a property map to supply the required map. Don't get confused between a property map, and “properties” meaning the fields of objects (beans). I noticed after making this tutorial that I had initialised my Map property to a new HashMap, which is kind of redundant since Spring will create a new Map; although it does at least allow us to run the toString() method of our bean when it has not had its property map set.
  • 18
    Arbitrary Maps as Bean Properties
    05:40
    Now it's time to look at setting a an arbitrary Map as the property of a bean.
  • SECTION 3:
    Autowiring
  • 19
    Autowiring by Type
    08:41
    So far we've been wiring our beans manually, but it's also possible to let Spring wire a lot of stuff up automatically. Whether that's necessarily a good idea in a given situation, is another matter. We'll take a look at how to wire stuff up by matching property types to bean types in this tutorial
  • 20
    Autowiring by Name
    05:55
    We can also autowire our Spring beans by matching their names or Ids to the names of set methods.
  • 21
    Autowiring by Constructor
    04:18
    Spring lets us autowire constructors by matching types of beans to constructor parameters.
  • 22
    Default Autowiring
    07:29
    What if we want to set a default autowiring method for an entire XML container? It's quite easy, and might save us a lot of typing – but be careful to avoid ambiguity and make sure you have all the right beans defined. Autowiring must always be used judiciously.
  • 23
    Removing Autowire Ambiguities
    04:49
    Spring has a trick or two for removing autowire ambiguities. We can remove beans from our list of possible candidates to autowire into other beans, or we can specify certain beans as primary autowire candidates, to be considered first.
  • SECTION 4:
    Wiring with Annotations
  • 24
    Adding Support for Annotation-Based Wiring
    05:44
    XML isn't the only way to configure Spring; these days we can also wire using annotations. In this tutorial we'll adding some stuff to our XML to support annotation-based autowiring.
  • 25
    The "Autowired" Annotation
    07:54
    The most basic wiring annotation is perhaps the Autowired annotation. We can add this annotation in various locations to our Java code to get Spring to wire up our beans.
  • 26
    Optional Beans
    02:34
    The “required” attribute on @Autowired enables us to specify optional beans. I was a little confused in this video over why Autowired sometimes tolerated ambiguity; now I think a large part of what was happening was that Autowired just decides not to consider a bean a candidate when it's used it once already! One lives and learns …
  • 27
    Using Qualifiers
    07:59
    The @Qualifier annotation enables us to further narrow the bean selection considered by Autowired.
  • 28
    The Resource Annotation (JSR-250)
    03:58
    Back in 2006, another annotation was introduced into Java to support dependency injection. We can use it quite happily in Spring, as an alternative to Spring's native Autowired. If you have problems using @Resource, check your project properties and ensure you're building with JDK 1.6 or later.
  • 29
    Annotation-Based Init and Destroy Methods
    02:20
    We can use some JSR-250 annotations to specify init and destroy methods.
  • 30
    The Inject annotation (JSR-330)
    04:58
    Winding forwards to 2009, JSR-330 introduced yet more annotations; @Inject is now one of Java's standard dependency-injection annotations, and of course we can use it in Spring. If you can't find @Inject, make sure you've added the right jar (you can add it via Maven) and ensure that your project is set to build with Java 1.6 or later.
  • 31
    Automatic Bean Discovery
    04:48
    We can ditch the XML and tell Spring which classes are to be used to create beans just using annotations.
  • 32
    Setting Property Values via Annotations
    03:42
    We can use the @Value annotation to supply values for properties. Later on we'll take a look at SPEL, which will make this a whole lot more interesting.
  • SECTION 5:
    Spring Expression Language (SPEL)
  • 33
    Introducing SPEL
    13:29
    Spring Expression Language makes property values dynamic, allowing us to run code and figure stuff out when we're busy wiring our beans. We'll also take a look at the “safe navigation” operator.
  • 34
    Using SPEL with Annotations
    05:16
    We can use SPEL with annotations too; the “Value” annotation will accept SPEL expressions.
  • 35
    Some useful SPEL Operators
    07:29
    In this tutorial we'll take a look at some useful operators that we can use in SPEL to create new objects, access static methods and perform arithmetical and logical operations.
  • SECTION 6:
    Working with Databases
  • 36
    Creating a Database with MySQL
    14:30
    A brief review of how to create a database with MySQL. I won't cover MySQL or SQL in any depth in this tutorial series, but we'll go over the basics.
  • 37
    Using Property Files
    08:50
    Since we'll need to store database connection info in a config file, let's take a look at reading property files in Spring.
  • 38
    Implementing the DAO Pattern
    04:29
    We'll use the DAO pattern to work with data retrieved from the database in Spring; in this tutorial we'll create a couple of objects that we'll be using a little later on.
  • 39
    Downloading a Connector Jar
    03:06
    We'll need a JDBC connector jar to connect to our database. If you're using an open source database like MySQL, you can probably do this via Maven. Otherwise you'll have to do a little Googling for the right jar.
  • 40
    Configuring Connection Pooling with Apache DBCP
    11:46
    Usually we use connection pools in Spring when we connect to databases. Later on, when we look at Spring MVC for web applications, we'll use connection pools provided by our application server. Since we're just creating a plan Java app here, we'll need to use an external (free) technology to pool our database connections.
  • 41
    JDBC Templates
    04:44
    We use various “JDBC Templates” in Spring to run SQL. In fact, we'll mostly get by using the simplest variety.
  • 42
    Querying the Database
    12:08
    Finally it's time to do a SQL query on our database. We'll use our JDBC Template to set the properties of a list of DAO beans, corresponding to the rows in our table.
  • 43
    Database Exceptions
    06:18
    Spring saves us from having to handle millions of JDBC exceptions; but we can still handle them when we want to.
  • 44
    Named Parameters
    10:12
    While JDBC allows us to use indispensable placeholders in SQL, Spring goes further and lets us used named placeholders, reducing the possibility of bugs and confusion.
  • 45
    Update Statements
    05:11
    It's very easy to execute SQL update statements in Spring; in this tutorial we'll implement a “delete” method.
  • 46
    Getting Placeholder Values from Beans
    08:11
    In this tutorial we'll add a “create” method to our DAO; we'll also see a very nice way of getting values for placeholders directly from your beans.
  • 47
    Adding an Update Method to the DAO
    06:30
    For the sake of completeness, we'll add a “update” method to our DAO in this tutorial.
  • 48
    Batch Updates: Prepared Statements
    11:39
    The Spring equivalent of a prepared statement is a batch update. We'll look at running SQL queries with multiple different placeholder values in this tutorial.
  • 49
    Transactions
    11:58
    Of course we can also do transactions in Spring, enabling us to run a bunch of statements in a failsafe manner.
  • SECTION 7:
    Web Application Basics with Spring MVC
  • 50
    A Basic Non-Spring Web App
    08:18
    We'll start our foray into web apps by creating a non-Spring web app; then we'll Springify it later on. You'll need either Eclipse EE or Eclipse Java IDE + WTP Plugin to get this working, along with a Java application server such as Tomcat.
  • 51
    Bringing in Maven
    05:37
    The next step is to add Maven support to our Eclipse project and bring in the necessary Spring jars.
  • 52
    The Dispatcher Servlet
    12:17
    The first step towards turning our web app into a Spring web app is to add a dispatcher servlet; this is the Spring servlet that will handle all our requests within the Spring MVC architecture.
  • 53
    Adding a Controller
    07:21
    After hitting the dispatcher servlet, requests are routed to a Spring controller in a Spring MVC web app. Here we'll add a single controller.
  • 54
    View Resolvers
    08:55
    Finally we can get our Spring web app actually working. In this tutorial we'll add a view resolver that will tell the dispatcher servlet how to interpret the logical view name sent back from our controller.
  • 55
    Adding Data to the Session
    07:49
    We need to figure out some kind of a way of passing data from our controller to our view, using the soon-to-be-added data model. We'll make a start on it here by looking at how Spring lets us add data to the session.
  • 56
    Using Spring Data Models
    12:15
    Spring has a bunch of easy-to-use data model classes that will make passing data from the controller to the view code quite simple. We'll take a look at a couple of possibilities in this tutorial.
  • 57
    Using JSTL (JSP Standard Tag Library)
    10:08
    In this tutorial we'll add JSTL support to our application. JSTL lets us use special tags in our HTML to output data, create loops, output stuff conditionally and do lots of other useful stuff, all without mixing up our view code with Java implementation code.
  • 58
    Configuring a JNDI Data Source
    21:28
    Java application servers like Tomcat provide us with a way of setting up connection pooling; the precise method you need to use to set up and connect to your connection pool depends on your server and database, and your hosting service. Here we'll look at setting up a JNDI data source for Tomcat 7 and MySQL.
  • 59
    Bringing in the DAO Code
    07:29
    Now we can copy over our DAO code from previous tutorials and configure a context container (XML file) to create the necessary beans.
  • 60
    Loading Bean Containers with ContextLoaderListener
    09:27

    We can use a special Spring class to load extra XML files. Our configuration for this project is actually going to be split among multiple XML files, which we'll load at startup.

  • 61
    Creating a Datasource Bean
    06:16
    Spring has a special tag which sets up a data source bean for us that will connect to our JNDI data source.
  • 62
    Adding a Service Layer
    15:00
    We're almost ready to display our data via Spring, but first we need a service layer. Our “service” class will simple be a class that's responsible for organising and using our DAOs, instead of cluttering up our controllers with this code.
  • 63
    Adding a New Controller
    11:24
    Just a bit of reorganization in this tutorial. We'll add a second controller so that we can have a separate home controller and offer-related controller.
  • 64
    Getting URL Parameters
    05:58
    Spring makes it very easy to get URL parameters. We'll take a look at how to do it here, because it'll be good preparation for getting the results of form submissions later.
  • SECTION 8:
    Working with Web Forms
  • 65
    Creating a Form
    11:29
    We'll do a little bit of config in this tutorial, followed by creating an HTML form that we can use to create new “offers” in our database.
  • 66
    Getting Form Values
    05:39
    It's really easy to get the values that the user has entered in a form. Amazingly easy!

    Also, Yavuz Yurtbeğendi tells me that you might need the attached XML fragment if you have problems with unicode characters.

  • 67
    Adding CSS Styles
    09:38
    Let's add a few CSS styles so that the form looks a little bit less ugly.
  • 68
    Serving Static Resources
    10:03
    We can get our DispatcherServlet to serve static content, such as a CSS stylesheet or images.
  • 69
    Adding Hibernate Form Validation Support
    13:00
    By making use of some Hibernate stuff, we can get Spring to validate our form. We'll start by adding some simple validation to one form field.
  • 70
    More Form Validation Tags
    07:43
    Let's finish adding validation tags to our form.
  • 71
    Making Forms Remember Values
    08:45
    We can easily make our forms redisplay entered values when validation fails, so that the user is not forced to enter everything all over again. To do this, we'll use some special Spring form tags.
  • 72
    Displaying Form Validation Errors
    06:31
    It's important to tell the user why a form failed to validate; nothing is worse than not knowing why a form has failed to validate. So let's add some validation error messages to our form.
  • 73
    Creating a Custom Validation Annotation
    18:42
    You may never feel the need to create your own custom form validation constraint annotation; after all, regular expressions give you a lot of flexibility. But just in case you want to know how to make a totally new constraint annotation, here's the lowdown.
  • 74
    Hooking Up the Controller and Database Code
    10:10
    Let's wire our database code into our controller now, so that our form actually does something useful.
  • 75
    Exception Handling in Spring MVC
    12:42
    What if our database code throw an exception? Spring makes it easy to handle whichever exceptions you feel like handling. In this tutorial we'll add a page that appears when any database exception is thrown.
  • SECTION 9:
    Aspect-Oriented Programming (AOP)
  • 76
    A Base Project for Working with Aspects
    08:33
    We'll create a new project here to experiment with; there's no new Spring stuff in this tutorial, except that we'll add a new dependency, spring-aspects.
  • 77
    A Simple Aspect Example
    13:01
    Now we can turn our Logger bean from the last tutorial into an “aspect”, containing “advice” which is run at a “join point” specified by a “pointcut”. Phew :)
  • 78
    Annotation-Based Aspects
    12:34
    Annotations being all the rage in Spring these days, let's see how you can do aspect-oriented programming using aspects. As we'll see there are pros and cons to using annotations here, but we'll stick with them in these videos because they at least avoid us having to do loads of XML configuration and take us back towards real programming ...
  • 79
    Wildcards in Pointcut Expressions
    15:27
  • 80
    Advice Types: After, Around and Others
    11:03
    “Before” advice isn't the only kind of advice we can use. We'll take a look at an arrange of advice types in this tutorial.
  • 81
    Proxies, Interfaces and Aspects
    12:48
    It's important to understand the relationship between Spring's proxy objects and the target objects they represent. Otherwise, you'll be prone to casting beans to the wrong type. We'll delve into the mystery and figure out how to avoid problems in this tutorial.
  • 82
    The “Within” Pointcut Designator
    03:55
    In this tutorial we'll see a new way of defining pointcuts, using “within” instead of “execution”.
  • 83
    “This”, “Target” and Matching Subpackages
    08:21
    We'll look at two more pointcuts designators in this tutorial; “this” and “target”.
  • 84
    Annotation-Specific PCDs
    13:16
    There are a bunch of Point Cut Designators (PCDs) that are designed to target annotations; we'll explore them in this tutorial.
  • 85
    The “Bean” PCD
    02:41
    The Bean PCD lets you target beans, and supports asterisk wildcards.
  • 86
    The “Args” PCD
    07:43
    “Args” lets you match methods based on argument types; it's fairly straightforward, although there are a few complications, as we'll see.
  • 87
    Getting Target Method Arguments
    03:02
    We can get the arguments being passed to our advised methods; there are two good ways to do it, and we'll look at the simplest in this tutorial.
  • 88
    Getting Arguments Using “Args”
    06:54
    We can also get method arguments using the binding form of “args”, which we'll take a look at here.
  • 89
    Combining Pointcuts
    06:06
    You can combine multiple pointcut designators in a single powerful expression.
  • 90
    Introductions: Adding Functionality Using Aspects
    10:55
    Aspects allow you to add extra functionality in to your bean proxies. We'll take a look at adding some simple dummy extra functionality to our beans in this tutorial.
  • SECTION 10:
    Spring Security and Managing Users
  • 91
    Servlets Filters: A Review
    09:02
    Let's start by reviewing what a “filter” is and how it works.
  • 92
    Adding a Spring Security Filter
    09:43
    We'll start adding security to our website by adding a Spring filter that will monitor all incoming requests.
  • 93
    Adding a Spring Login Form
    17:24
    Now we can set up a Spring default login form, allowing people in only when they type the correct user name and password.
  • 94
    Serving Static Resources: Access Rules
    02:49
    Using what we've already learned, we can easily add some access rules to serve static content such as CSS files and images.
  • 95
    Customising the Login Form
    09:50
    We can supply our own login form to replace the default Spring one, which we can then customise to our hearts' content.
  • 96
    Displaying Login Errors
    09:03
    If the user types an incorrect username or password, it'd be good to tell them so. We'll add a login error message to our form in this tutorial.
  • 97
    Authorising Users from a Database
    13:35
    So far we've been hardcoding user names and passwords in our XML config file, but it'd be much better to start this information in a database. One possibility is to use an LDAP database, but here's we'll make use of our existing MySQL database (or we could use any relational database) to store user names and passwords.
  • 98
    Adding a “Create Account” Form
    16:07
    Let's add a form that allows people to create new users, in other words, to register on our website.
  • 99
    Making the “Create Account” Form Work
    18:20
    No new Spring stuff in this tutorial, but we'll add database-related code to made the user creation form work.
  • 100
    Adding Validation to the User Form
    17:30
    We'll add validation to “User” in this tutorial; once again, no new Spring stuff, but we'll apply stuff we've previously learned.

UDEMY BY THE NUMBERS

5,200,000
Hours of video content
19,000,000
Course Enrollments
5,700,000
Students

RATING

  • 125
  • 4
  • 2
  • 1
  • 2
AVERAGE RATING
NUMBER OF RATINGS
134

REVIEWS

  • Shafiur Rahman
    Excellent

    Nicely grouped in to related sections. Guidance is apt which even a beginner can follow.

  • Ozgen Gunay
    Great Course

    This course is beyond my expectations. The instructor is obviously a seasoned professional. I followed the course fully hands-on which is what I was expecting.

  • Collin
    Springframwork

    The tutorial is excellent,Thanks a lot!

  • Mohammad Rajaul Islam
    Highly Dedicated Spring Course I have ever seen

    Thanks for this highly Dedicated Spring Course I have ever seen. Lecture is clear and highly resourced. I appreciated His hard working.

  • Vineet Narayan
    Detailed topic coverage

    Use of actual project example to explain topics helped. And in course of the same, other technologies were also covered, which was a plus given that real-world applications do use them all in conjunction with spring for production go-live.

  • 30 day money back guarantee!
  • Lifetime Access. No Limits!
  • Mobile Accessibility
  • Certificate of Completion