1 00:00:00,300 --> 00:00:04,200 All right, we're back in IntelliJ and I have the build.gradle file open. 2 00:00:04,200 --> 00:00:07,290 Whenever you make a change to the dependencies, whether you've added or 3 00:00:07,290 --> 00:00:08,330 removed some, 4 00:00:08,330 --> 00:00:12,260 you can refresh the project's jar files through the Gradle tool window. 5 00:00:12,260 --> 00:00:14,640 With the Gradle project open like the one we have here, 6 00:00:14,640 --> 00:00:19,250 you can see the Gradle tool window by choosing View > Tool Windows, 7 00:00:19,250 --> 00:00:24,270 then Gradle and the window that pops up on the right here is the Gradle tool window. 8 00:00:24,270 --> 00:00:27,800 In this window you should see this refresh button. 9 00:00:27,800 --> 00:00:30,290 We'll use that to refresh the dependencies 10 00:00:30,290 --> 00:00:32,850 when we change them in the dependencies block here. 11 00:00:34,360 --> 00:00:38,160 Let's expand external libraries on the left panel here and 12 00:00:38,160 --> 00:00:40,800 see what's on the class path now. 13 00:00:40,800 --> 00:00:45,060 The first one is the Java core library for Java version 1.8. 14 00:00:45,060 --> 00:00:48,760 And the next two are the dependencies of our project. 15 00:00:48,760 --> 00:00:52,660 J Unit is a library that is listed as a dependency here in our profile. 16 00:00:52,660 --> 00:00:54,450 You see J Unit. 17 00:00:54,450 --> 00:00:59,920 And hamcrest here is a dependency of J Unit but Gradle figures that out for us so 18 00:00:59,920 --> 00:01:04,680 we don't have to explicitly list it as a dependency in the dependencies block here. 19 00:01:04,680 --> 00:01:06,550 That's the beauty of Gradle. 20 00:01:06,550 --> 00:01:10,710 And just to drive home the fact these external libraries are indeed jar files, 21 00:01:10,710 --> 00:01:15,780 let's expand each one of these, junit and hamcrest to reveal the fact that, 22 00:01:15,780 --> 00:01:20,770 yes, we indeed have a jar file here and a jar file here. 23 00:01:20,770 --> 00:01:24,460 I'm going to collapse these two dependencies and go into 24 00:01:24,460 --> 00:01:29,420 our dependencies block and delete what we have in here to add one of our own. 25 00:01:31,190 --> 00:01:33,670 Let's make it the main one we'll use throughout this course. 26 00:01:33,670 --> 00:01:36,330 The spring Web MD C library. 27 00:01:36,330 --> 00:01:39,220 This is the part of the Spring frame work that will allow us to write our web 28 00:01:39,220 --> 00:01:40,490 application. 29 00:01:40,490 --> 00:01:44,180 The basic way of adding a dependency in Gradle is by typing compile followed by 30 00:01:44,180 --> 00:01:46,014 single quotes, then the group name. 31 00:01:46,014 --> 00:01:51,016 Which in our case is org.springframework. 32 00:01:51,016 --> 00:01:55,535 We follow that with another colon, and then the group ID, which, in this case, 33 00:01:55,535 --> 00:01:56,541 is spring-mvc. 34 00:01:56,541 --> 00:02:00,541 Then another colon, followed by the version, 35 00:02:00,541 --> 00:02:07,250 which as of the recording of this course, is 4.2.1.RELEASE in all caps. 36 00:02:07,250 --> 00:02:08,540 I'll go ahead and save that file. 37 00:02:10,150 --> 00:02:12,930 If you're having trouble memorizing that, never fear. 38 00:02:12,930 --> 00:02:19,370 Switch to a web browser and and do a quick Google search of spring webmvc maven. 39 00:02:20,410 --> 00:02:23,190 I use maven here because the main repository we're going to 40 00:02:23,190 --> 00:02:24,880 use is called maven central. 41 00:02:27,290 --> 00:02:28,930 We see a bunch of search results here, but 42 00:02:28,930 --> 00:02:35,080 the one that we are interested in is the one that comes from mvnrepository.com. 43 00:02:35,080 --> 00:02:35,990 Let's click on that. 44 00:02:37,360 --> 00:02:39,540 There we see Spring MVC. 45 00:02:39,540 --> 00:02:45,014 We'll choose the version that we like, which is now version 4.2.2.Release. 46 00:02:46,430 --> 00:02:49,100 And we see a series of tabs here at the bottom. 47 00:02:49,100 --> 00:02:49,850 I'll choose Gradle, 48 00:02:49,850 --> 00:02:53,190 since that the dependency management tool that we are using. 49 00:02:53,190 --> 00:02:57,130 Here you see the exact line you need that follows the compiled key word, 50 00:02:57,130 --> 00:02:58,610 in your Gradle build file. 51 00:02:58,610 --> 00:03:04,800 So you can highlight that, copy it, then go back into Intelli J, and paste that. 52 00:03:07,090 --> 00:03:09,140 Let's review what we just typed. 53 00:03:09,140 --> 00:03:10,500 We have the compile keyword, 54 00:03:10,500 --> 00:03:14,630 which tells Gradle that we want this dependency available at compile time. 55 00:03:14,630 --> 00:03:18,570 That is, it's required in order for our source code to compile. 56 00:03:18,570 --> 00:03:23,050 Then we have the group ID, org.springframework followed by a colon. 57 00:03:23,050 --> 00:03:27,489 Then the artifact ID spring-webmvc followed by another colon. 58 00:03:27,489 --> 00:03:34,488 And finally the version, which is 4.2.2.RELEASE. 59 00:03:34,488 --> 00:03:37,337 To see Gradle in action, let's save this file, 60 00:03:37,337 --> 00:03:40,680 then click the Refresh button in the Gradle tool window. 61 00:03:42,250 --> 00:03:45,870 If you watch the external dependencies on the left you'll see them grow 62 00:03:45,870 --> 00:03:47,580 substantially. 63 00:03:47,580 --> 00:03:51,060 Here I'll reiterate an important feature of a dependency management tool 64 00:03:51,060 --> 00:03:52,070 like Gradle. 65 00:03:52,070 --> 00:03:55,242 It resolves dependencies for you. 66 00:03:55,242 --> 00:03:57,752 [SOUND] In the case of our Spring app, 67 00:03:57,752 --> 00:04:01,780 we need to utilize this spring-mvc library in our code. 68 00:04:01,780 --> 00:04:06,025 But this spring-mvc library has a bunch of dependencies of its own. 69 00:04:06,025 --> 00:04:11,861 [SOUND] Six of them to be exact, and two of those have yet more dependencies. 70 00:04:11,861 --> 00:04:14,333 So here is where I say thank you Gradle for doing so 71 00:04:14,333 --> 00:04:16,960 much with such little instruction. 72 00:04:16,960 --> 00:04:19,850 Okay, we've got our local environment set up to start coding and 73 00:04:19,850 --> 00:04:21,470 even our project created. 74 00:04:21,470 --> 00:04:22,500 After a quick check for 75 00:04:22,500 --> 00:04:26,770 understanding, we'll dive into the world of using Java to develop web applications.