Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Framework does not required sever. Is it true?

Tags:

spring

I read in spring tutorial in advantages section point no. 3. Spring Framework does not required server . Is it true ?

how can we run web application without any server?

like image 776
user2663358 Avatar asked Dec 30 '25 17:12

user2663358


1 Answers

Yes. You can run a standalone spring application.

Your main class will be the entrypoint, you can load the bean definitions using ClassPathXmlApplicationContext. E.g.

public static void main() {
   ApplicationContext ctx = new ClassPathXmlApplicationContext("ctx.xml");
   YourService service = ctx.getBean(YourService.class)
   service.doSomething();
}

Then everything in doSomething() can use dependency injection.


Update: Since you seem to need to run a webapp without a web server - you can't. You need a servlet container (which would be a 'web server' here). What you can do is use an embedded web server like jetty or tomcat-embedded and launch the process from a standalone app.

If by "web server" you mean a remote physical (or virtual machine) - you don't need it - you can install tomcat locally on your machine and run the application.

like image 85
Bozho Avatar answered Jan 01 '26 13:01

Bozho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!