Spring Boot support in Visual Studio Code | Spring boot with Microsoft VS Code|Spring boot in VSCode

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this lesson we are going to learn how to create and run a spring boot project on vs code as a prerequisite you should have Java and Maven installed in your system and Java home and mavin home properly set then in vs code we need to install the extension pack for Java and spring boot extension pack and then we would create a spring boot project from vs code ID and run it now along the way there would be certain customizations required if we consider real life scenarios and I would show how to customize those vs code settings for jdk runtime change let's get started so here I have my visual studio code or vs code opened I'm in the Explorer I can click on extensions and search for the Java extension pack search for the extension pack for Java let me type Java so here I can see extension pack for Java under this extension pack you can see there are six other extensions available if I scroll down these are all of them mavin for Java taste runner for Java and many others let me click on install so the the extension pack is getting installed I'll pause the video Once the extension pack is installed I'll resume now extension pack for Java is already installed let me look for the spring extension pack I can just type spring so if I type spring there are multiple entries you need to just select this spring boot extension pack as under this all of this would be available so here you can see there are three extension pack under it and this is from vmware.com so if I scroll down you you can see spring initializer Java support Spring boot tools spring boot Dashboard Etc click on install here also I will pause my recording once the installation is done I'll resume now the spring boot extension pack is installed so what I can do I can type control shift p or go to view command pallet or I can go to command pallet from here also manage command pallet here if I type spring it would be providing you multiple options right now we just want to to create a project create a maven project I have clicked over here here it is giving me multiple spring boot versions now one thing to notice over here it is only giving you specific latest spring boot versions it may happen that instead of this versions you want to use some old version so what to do in that case I'll come to that so let me pick this available version I'm selecting Java so here I need to provide the group ID I'm keeping it as is press enter this is the artifact ID this also I'm keeping it as is press enter the packaging type jar is selected let me press enter here the Java version 17 or 21 I'm keeping 17 now I need to select some of the dependencies here you can see there are different spring dependencies available I'm just going to select spring web let me type web so here I can see spring WB I can just select over here you can see it is showing selected one dependency I can select other dependencies if required but no need let me just press enter to continue now it's asking me to select a d Dory let me go to my custom location so this is a blank folder I have named it as allore vsor code let me click generate into this folder so the project would be placed over here so it is saying successfully generated location is this I'm clicking on open so it's asking me whether I trust this location or not I can check this box and click yes I trust authors let me get rid of this welcome screen now so if I expand this Source directory what I can see in this spring boot project this is the source directory there are many other files and this is the pom.xml so if I go to pom.xml let me see it has generated the standard structure with spring boot version 3.2.2 the Java version is 17 and rest all are standard now inside source directory I have Main and test under main there is Java and this is the spring boot application class let me try to run this right click run Java let me close this now here you can see this particular command is fired now spring boot is getting loaded so this demo application is started if I expand this a little bit and go up here if you notice there is one bundle jdk or Java it is using to run this particular spring boot application file and from here it looks its version is Java 17 now here if I go back to my pom.xml so the Java version that I'm using is 17 the spring boot is almost latest so I don't have any problem but suppose my local system I have Java 8 installed and I want to use some old versions of spring boot in that case what I would do so let me show you so here on one thing to notice when this application is invoked the command is like this and here it is using a Java which comes bundled within vs code and its version is 17 and it is using an argument file and then it is invoking the class up to this this is fine but I want to complete this application I have only this application class I want to add One controller and want to see the output in browser so for that I need to write some custom code so let me create a new class over here here new file dummy controller. Java press enter now this is my dumy controller that got created I'm going to add one annotation over here as rest controller and add the necessary import let me add a simple method over here so basically my request mapping here is Slash and it is going to return this particular message hello world Spring boot so I'm going to stop this application and run this once again right click run Java or I can run from here also so the application is started again let me go to the browser the URL is HTTP colon // localhost colon 8080 now we can see it is returning an output hello world comma spring boot so what I have done I have created a spring boot application from vs code using the spring boot extension pack and now it is running that is fine but in real life you will face certain problems for example if I go back to my application whatever vs code has provided me I have used it if I go to pom.xml here my spring boot version is 3.2.2 but in real life you may use some other versions some older versions and also it is using Java version 17 now by default with my existing vs code Java 17 is there in the bundle but what if in my local system only Java 8 is available or or some other version is available how would I manage that so let me see that I'm going to close this run now here where certain vs code settings related concept is required let me change this Springwood version to some older version maybe 2.7 do something okay 2.7.8 as you can see it has the control assist if I change this version the different versions are coming and also locally I have Java 8 installed so instead of 17 I'm going to use Java 8 let me save it but now I need to tell vs code that where my Java 1.8 version is present for that I need to change something in the settings we can go to view command pallet and then we can see configure Java runtime that is one way here what it is showing it is showing this project specific entry I can edit over here and change the value but that is not the way what we want we can go to settings from here so click on the settings so here we have user and workspace so what is user settings and what is workspace settings if I go back to vs code documentation so this is the website code dovisual studio.com under that/ dooc get started under settings so here it says what is user settings and what is workspace settings user settings that apply globally to any instance of vs code you open so it is more of global workspace settings is the settings stored inside your workspace and only apply when the workspace is opened so it is more of folder level or project level setting so here if I go back to my vs code by default user is selected so if I want to customize something at a global level I'm going to use this but this one I want to customize only for my current project so that it uses jdk8 only so what I can do over here I can search for a particular option which I want to customize so let me look out for the Java options type Java if you see Show release notes completions enabled debox settings many things are there I don't see the option for Java runtime anyways I can click on edit in settings so here what I need to do I need to add a new Option press Escape I don't want to make any change related to Java debugging so give a comma and here just type Java do configuration. runtime this is what I want and here I need to add certain values so if you type control space it is giving you an entry again type control space name Java 8 press control space path so here I need to provide a path and vs code already suggesting me for window back slashes must be escaped let me copy paste my jdk8 location over here now what I have done I have added Java runtime configuration I have provided the name like this and also the path of my jdk so let me try to run the application once again so two things we have done we have changed the p. XML so that a different spring boot version is used a different jdk is used and also accordingly we have changed the Java runtime configuration under the workspace settings if you see here this is workspace and this is user one thing you can notice while I added this change at workspace Level under this project under this vs code this settings. file got created which actually contains all this customizations let me close all this I'm going to clean the old entry so let's run from here right click what I can see the application is now started if I scroll up I can still see it is still using the J from vs code although I have provided a runtime configuration maybe the vs code is not refreshed let me stop it and restart this let me cl vs code I'm opening it once again let me go here inside settings.on Java run time configuration is there let's try to run the application once again right click run Java now again the spring boot application is running let it get started if I scroll up now it is taking the Java so probably the runtime which I changed over here it did not get refreshed but now it is working as expected let me go back to the browser so the change code is running fine let me make one small change over here in the controller I'm just changing it to Spring boot 8 just to see my change is reflected let me restart it it's restarted now refresh the page spring boot 8 so what we have done so far we have learned how to create and run a spring boot application in vs code and also more importantly in real life scenarios where I need to change the Springwood version when I need to point to my own jdk rather than the higher versions of the jdk that is available by default in vs code how to adjust to it we learned how to modify the settings file and accordingly make vs code work for me so that is all for now I would request you to subscribe to this Channel and like the video thanks a lot
Info
Channel: LearningFromExperience
Views: 6,793
Rating: undefined out of 5
Keywords: spring boot, visual studio code, vs code for spring boot, vs code spring boot, spring boot using vscode, spring boot on vscode, how to install spring boot on vscode, writing code on vscode for spring boot, java and spring boot on vscode, spring boot on visual studio code, spring boot java, Installing Spring Boot Extensions in VS Code, vscode java setup, Spring Boot support in Visual Studio Code, VS Code for Spring Boot Java Development, spring boot tutorial, vscode spring boot
Id: RBmWIACTiKI
Channel Id: undefined
Length: 12min 17sec (737 seconds)
Published: Mon Jan 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.