How to Configure Jetty Server with SpringBoot App

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi guys welcome to some defined Tech and programming so in today's session we are going to check how we can use Jetty server in our springboot macro service or spring boot application so in other way like how we can migrate from inbuilt embedded Tomcat into spring boot to JT server okay so what is jts so JT is a basically open source web server and a server container so additionally it provides support to http to protocol websocket osgi jmx jndi and Jazz and many other integration so these components are open source and they are freely available for commercial use and distribution so Jetty is used in a wide variety of projects into development and production so it can easily embedded into our microservices devices tools Frameworks and application servers okay and uh like a while to use JT so these are some features where like we can choose the JT instead of other servers like it is a fully featured and standard base it is open source commercially usable then it's a flexible and extensible it has it is a embeddable also so like we can embed instead of Tomcat it is a synchronous Enterprise and scalable and dual license under Apache and Eclipse okay so this is a small intro about Jetty so now let's dive into our program okay so here I am using this spring toolsuit so this is like extended eclipse so here I am creating this create new spring starter project so click on this so first we will create a by default spring boot micro service and then we will migrate that to JT server so type is a maven their packaging as a jar Java version 8 and language Java so let's say next we can choose the uh Library as a spring web this is the dependency we required so inside the spring web we have this Tomcat container okay so this project is created let's go to home.xml okay so spring boot is using this artifact that that is a springboard starter web so that embedded Tomcat is lying inside this starter web so in order to verify this so we will generate the dependency tree so go to run configuration and this is the goal that is a dependency colon tree so we need to exhibit this goal okay so this goal is completed let's search for Tomcat okay so if you can see this spring framework dot boot.springboot starter Tomcat so this is coming so you can observe this child into this parent this is the parent this is the spring boot starter wave so inside this this Tomcat is there okay so we need to exclude this Tomcat so now how to exclude this so and we have to add this JT server okay before excluding so let's uh create One controller and let's create one rest call and we'll see if it is running with the Tomcat okay so here this is the our entry point for the spring boot here declare this as a rest controller so so now we have to add one rest mapping so for this arrive at the rate get mapping okay so inside this gate mapping let's say we are going to call I will drop that so now forget message hello from next string yeah that's it so let's run this okay so now you can observe this Tomcat started on port 8080 and our application is started so now let's verify if our application is running so go to browser and type localhost colon 880 slash hello Tom Cat so you can see so we we got the message hello Tomcat server so now we will exclude we will migrate this Tomcat to uh jte container okay so for that we just need to exclude this Tomcat dependency so we've previously seen this dependency into this uh starter wave so so here you need to write one exclusion so type exclusion okay so insert this exclusions so we have to write one single exclusion so that is equation okay okay so what we have to exclude so just copy this we need to exclude the library inside this parent Library so what is this so that is Tomcat so now save it and stop this application and try if Tomcat is running or not so I will run the same application again okay so it is saying that started this application but there is a no search container is there so there is no web server restarted so if you try to run this application also then also it will not run yeah so it is not running so we need to now we have excluded the Tomcat now we have to include the Tomcat include the the dependency which is having JT server so copy this okay and here instead of web you can type that's it so we have added this dependency we have excluded tomcat and we have included this Yeti so now again we can run this application okay so by using Jetty so our application start fail so why it is failed because uh in Spring latest version so you can see this is the 3.0.2 version okay so basically this package is not available into latest version of spring so instead of that like they have migrated to another package of Jakarta okay so in order to solve this so we have to download the downgrade this version so for now we are taking 2.7.8 okay and we are just again building this application okay so if you can see this message so JT started on port 8080 and our spring boot application is also started okay so now let's verify this if our application is running fine so go here copy this oh now okay wait a second so here we will write hello jetty hello JT server save it and let's stop this once and let's restart this application okay so it is started so let's verify this copy this go to the browser and type localhost again colon 8080 slash hello JT yeah that's it so we got this message hello JT server so that is from here hello JT server and from this JT server only so there is a no Tomcat so you can verify this also by use by creating the dependency tree so go to run configuration okay and here generate this dependency tree okay so build a success let's verify search for JT okay so you can see like in in Spring web so this is the starter wave so in starter web so we have this spring boot starter JT instead of Tomcat okay so we can see Jakarta servlet API so in three uh 3.0 version of spring boot so this Jakarta server it is servlet is 6.0 but that is moved into another package so that's why it is not able to start okay so this way like we can migrate from Tomcat to JT server that is like inbuilt server configuration for Tomcat or source for sorry for spring boot yeah so that's it for today stay tuned for further interesting sessions and thanks a lot for watching [Music]
Info
Channel: Simplifying Tech
Views: 871
Rating: undefined out of 5
Keywords: How to Configure Jetty Server with SpringBoot App, spring boot, jetty server, hot to configure, spring, pom, how to use jetty server with spring boot, how to use jetty server in spring boot, how to configure jetty server in spring boot, jetty server spring boot, jetty server in spring boot, jetty server with spring boot, spring embedded jetty server, spring boot jetty server, how to exclude embedded tomcat in spring boot, how to remove embedded tomcat in spring boot, java, springboot
Id: CD7MAaOH7Z4
Channel Id: undefined
Length: 10min 32sec (632 seconds)
Published: Fri Feb 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.