Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Spring in a standalone application

Tags:

java

spring

i am looking for samples or tutorials of using Spring in a standalone (desktop/swing) application, i searched a lot but couldn't get to something useful, all the examples and tutorials are for web applications, please advise.

like image 953
fresh_dev Avatar asked Nov 12 '11 14:11

fresh_dev


People also ask

Can I use spring boot for standalone application?

Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications. Spring Boot provides various starters for building standalone or more traditional war deployments.

What is standalone spring based application?

Spring is a popular Java application framework. It provides various libraries and tools for enterprise application programming. It is also a very good integration system that helps glue together various enterprise components. Spring ApplicationContext is a central interface to provide configuration for an application.

Can spring be used for desktop application?

With Spring, you can build production-ready spring applications. Mostly, Spring Boot is used for web applications, however, it has many capabilities to be a perfect fit for your desktop application.


1 Answers

  1. Create the standalone application with maven, as pointed here:

    Create a standalone application with Maven

  2. Put the applicationContext in classpath, and load it in the main class as follows:

    ClassPathXmlApplicationContext ctx =          new ClassPathXmlApplicationContext("applicationContext.xml"); 

    See full article here:

    http://www.devdaily.com/blog/post/java/load-spring-application-context-file-java-swing-application

like image 148
Mahmoud Saleh Avatar answered Oct 04 '22 12:10

Mahmoud Saleh