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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With