Develop Container-less Application with Spring Boot.

If you first started developing Java-based web applications a few years back, you might recall that you first constructed a web application before deploying it on a web server or app server.

The difference between Web server, Web container and App server.

Your trusted Apache server, which uses port 80, is a web server. After deploying some PHP, HTML, or other file, you can launch this web server. A server that manages HTTP requests is known as a web server. Also, no Java EE specification may be handled by a web server. The following phase is Web Container. A portion of the Java EE specification can be handled by web containers. It consists of servlets. Application servers can handle the entire Java EE standard. Application servers handle RMI calls in addition to HTTP requests, among other things.

Container Applications.

A container can handle several applications when you transfer your web application to it. If you have 10 applications running in a single container (for example, a JBOSS server), and one of them encounters an issue, you must restart the entire container. The other 9 applications will all then become inactive. Now that we deploy our applications to the cloud, restarting your web container is typically not an option. Additionally, it would be difficult to maintain them if you used multiple configurations for other web apps, as it is challenging to configure two distinct versions of the same configuration for two separate applications. Developers therefore created a container-less application as a remedy for this.

Container-less Application (Container Embedded into Application).

In the event that you need to apply some configuration or something, you must restart the container if you have one and are moving your web application to it. As an alternative, you can integrate your web server or container inside your application. Therefore, when your web application is launched, a container will be started and it will operate on top of that container. That implies that your program will create a container on its own. As the container’s lone dependent and only dedicated to that application, anything can be done to it.

Advantages,

1. We can do a restart.

3. We can have own configuration because it is owned by us / our application.

3. You will get public static void main method (you couldn’t use main method in web applications) as you are developing just a java application.

The only issue is that you’re integrating your server into that. As a result, when your application is launched, a container will be created and used.

Microservice Frameworks,

  • Spring Boot
  • Dropwizard
  • Spark

Spring Boot.

One of leading framework which has very good performance, memory footprint and process usage etc. It comes with dependency injection frameworks and everything. Frameworks have its own HTTP server, REST API, implementation framework and other utilities. Spring Boot comes with Spring and Apache. You only have to focus on implementing your business logic. Spring is fully open source project.

Example :- How to Build Container-less Application with Spring Boot.

  1. Create Spring Boot Project. (am using Spring Initializer from www.start.spring.io )/you can use spring supportive IDE or same Spring Initializer.
Step 1

2.You can added Spring Web Dependency and Spring Parent. (line 5–10 & 20–23)

Step 2, pom.xml file

Please take note that the spring boot application’s annotation is required. You won’t be able to build the server.

Step 3, Application.java file

Otherwise, it won’t work, so you must declare this as a RestController. Look at the picture.

Step 4, GreetingController.java file

The can the execution of the main method. See below the picture.

Step 5, Execute the Main Class.

You can open up your browser and go to localhost:8080. you visit the site, you can see the message you have coded in the application.

Step 6, Browser View.

You can customize and download the project zip file from the below link.https://start.spring.io/

Reference :-

Krishantha Dinesh, Develop Container-less Application with Spring Boot, Nov 23, 2016,

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gawesh Prabhashwara

Gawesh Prabhashwara

Software Engineer at Virtusa | Trainer & Instructor