Choosing an IDE for Spring Boot
Welcome back, aliens. My name is Naveen Reddy. So, once we have seen the theory of Spring Boot—so why do we need Spring Boot and what features it provides—it's time to create an application. But before going for the application, of course, we have to do a software setup, right? Now when I say software setup, basically we need an IDE, which is Integrated Developer Environment.
Now, which IDE do we have to use here? Of course, everyone has their own favorite IDs available, right? Example, some people do love NetBeans, some people love Eclipse. Now for Spring, which one to use? Of course, we can use NetBeans, and NetBeans does provide you in-built plugins for that. You can also use Eclipse, or one of the best ones for Spring itself is STS. Now Spring belongs to Pivotal, so they have their own IDE which is STS. And if you want to go for the paid version, you can go for IntelliJ.
So if you just go to Google and search for—so if you search for IntelliJ, I'll just click on enter, you can see this is the official website which is from JetBrains. And you can download the IntelliJ IDE. The only problem is it's not free for spring. So they have two versions: one is the community version and the second one is the enterprise one, or the ultimate, which you say.
Community is free. So if I click on download you can see we will be having two options. So Community is free, but then if you want to work with Spring Framework, you need to go for the commercial one, which is Ultimate. And commercial provides you Spring features. So you can go for this one. So people who are working in Java, Java environment for a long time, and they think they want to invest so that it will improve their productivity, of course you can go for IntelliJ. Otherwise, in this series, we'll be using STS.
Now STS is a Spring Tool Suite. This is developed by Pivotal, and this code, this works better if you want to go for Spring Boot. Now, is it a very different IDE? The answer is, if you have already worked on Eclipse, this is almost similar because this is based on Eclipse IDE. So when I click on download for this, so I have Mac, so I'm using this. So I've just clicked on this. If you're using Windows, you have to get a Windows option there and you can see it is downloading now. So you can see I have a setup here. Now once you have downloaded the setup, you just have to double click it if you're using Mac. Otherwise, for Windows, you just need to unzip it and it works perfectly.
So for Mac, you just have to do some extra stuff. You have to shift the STS to the applications so that you can directly access from the application folder.
First Launch and Workspace Setup in STS
So if I see my application, you can see we got STS here. So if I click on STS, it will take some time to open, as I'm doing it for the first time. So once you have opened STS, it will ask you for the workspace. Now for this, what I will do is I will say 'spring-tutorials' or 'spring-tuts' and click on launch. Now, what it will do, it will open your STS and all the projects will belong to that particular folder which you mentioned there. And you can see, we got STS open. People who have worked on Eclipse, they know this is the same, right? So if you run Eclipse you will see the same screen.
Now if I go to about STS, you can see it says it is based on Eclipse platform. So it says build version this one and platform is Eclipse Oxygen. So ultimately you are using Eclipse. The only thing it provides you is shortcuts to make Spring applications.
Creating a New Spring Starter Project in STS
Now how do we create our first Spring application? It's very simple. You just right-click it and you say new. Now if you are making a normal Spring application, you can simply select a Maven project, and you can select a Spring. Otherwise, if you are creating a Spring Boot project, this is amazing, we have Spring Starter Project option. Now you will not get this option directly in Eclipse, okay? So that's the advantage of using STS. Click on this one.
Now it will ask you for the service URL. Now why all these things? Because when you create a normal project in Eclipse, it's straightforward. You just say next, next, next. But here, now since we are using Spring Boot, the thing is Spring Boot, as I mentioned, it is an opinionated project which you get. That means the feature which you need, it will give it to you. You don't have to do much configuration, as it also supports autoconfiguration. So what happens is whatever project you need, you will be getting that project from the official server. So they have this service called as start.spring.io. So anyone, you need a project, you need to go to this website and you download the project. That means you need an internet connection to create a Spring Boot project, and of course, everyone has it nowadays.
So the app which you want, the project which you want to work on, so the basic structure will be getting downloaded from the official website. So for that, we have to give a proper name to it. We can give any name, doesn't matter. I would say 'first-project'. Now you have a choice because you can select either Maven or Gradle. That's your choice. I prefer Maven, I would go for Maven here. And then you have to mention your Group ID, you have to mention your version number if you want, Artifact. I will keep it as it is, I will not change it at this point. Maybe in the next video, we'll create a new project with different names.
Selecting Dependencies and Finishing Project Creation
And then I will click on Next. Now here you can Cce it's just giving you so many options. And this is the best thing about Spring Boot. You know, the time I'm making a video, we also got Spring 2.2. Earlier I was working on 1.5, but then 2.2 got some new features. It does support Spring 5, it does support reactive programming. As of now, we are not going for all those stuff. So let's keep it what it is there. And then if you want to, let's say, if you want to work with Spring JDBC, it's very simple. You just type JDBC and then you can select this one.
The amazing part about Spring is it does support autoconfiguration. So if you have not provided any manual configuration, it will do it for you. But since this is our first video, let's not get into that. I will skip all those things as it is. Click on Next and click on Finish. The moment you click on Finish, you can see your project is coming from the official server, and you can see the progress here. It is downloading from the official server and that's why it takes some time to build the project. And if I expand this, it is still in the, you know, downloading phase, so it will take some time to complete these steps.
Alternative: Using Spring Initializr Website with Eclipse
What if you are not using STS? What if you want to get this project? What you will do? So if you are using Eclipse, it's very simple actually. So let's say you have Eclipse, and when you open Eclipse, how you build that project? Because if I say right click... so this is Eclipse, okay, so if I click here, if I say New, you can see... you can see we don't have spring starter project option. In this case, what you do is you just have to search for start.spring.io. This is the website where you can download the app. So this is Spring Initializr from where you can download this stuff. So you can see we have Group ID, you can name it, let's say 'first-project', the same name which I'm giving. And then if you want a dependency, you can just type it here. As of now, I don't want to change anything. Simply click on Generate Project and you can see it will give you this zip version. You just have to unzip it, and then in Eclipse, you just have to import the project. You will get the same thing which we got in STS.
So the only advantage, or one of the advantages of STS is you don't have to go to the official website, you don't have to download that. You will get that directly, as we get the option.
Running Your First Spring Boot Application
And you can see we got our Spring Boot project here. Again, we'll not be doing any much code here. It's just a simple Spring boot project. Maybe I can print 'Hello World' just to show you if this thing works. And you can see I got some code here. Nothing to worry about, we'll talk about this later. I will simply type sout and here I would say 'Welcome to Boot'. That's it, nothing much.
Now, how do we run this project? Now we can run this project normally as a... normally we do, Run As > Java application. But then if you want to use Spring features, of course, you have to go for the second option which is Spring Boot App. Let me just click on that. Now this is extra features which you get, and that's why it will take some time to do. And you can see we got the output as 'Welcome to Boot'.
At this point we have not used any Spring feature, okay? We'll do that later. But this is our first application. So this is our head start for the first code of Spring Boot. Remaining code you will see in the subsequent video, so stay tuned. Now, if you enjoy this type of videos and if you want the complete theory of Spring Boot, let me know in the comment section. And if you enjoyed, do click the like button. And thanks for watching everyone.