Developing A Simple Java Application With Spring

Updated 3 months, 3 weeks ago

Source: http://www.solitarygeek.com/

Introduction

Spring is a powerful application framework that can be used across any layer in your application. For example, you can use Spring to manage only your data access layer or you can use Spring to provide remote services for your swing client. In this article, I will explain how to get started with Spring by developing a simple java application.

Requirements

1. Your favorite IDE

2. Latest Spring framework.

(Note: This article makes use of Spring ...

  • 25 comments on this story
PRO

50% positive

Showing 18 relevant reactions out of 25.

@James

thank you man, with the help of Spring and right now i have the basic understanding of Spring framework.

Don’t you have more tutorials on Spring,Hibernate,JSF,Junit and Integrator development.

Please help me James

@styls

3 months, 3 weeks ago by Styls on Wordpress

@Styls

No you don’t need a specific jar file. This xml file can sit side by side with your java source files. Please see the last image in the post above to get more insight.

3 months, 3 weeks ago by James on Wordpress

James

You saying this code requires a specific jar file..

reason I;m saying this is that, it the only code that is give me some difficulty.

please help.

ApplicationContext context = new ClassPathXmlApplicationContext

(”resources/applicationContext.xml”);

i don’t understand this part– please can you explain it.

3 months, 3 weeks ago by Styls on Wordpress

@Styls

Styls :

ApplicationContext context = new ClassPathXmlApplicationContext

(”resources/applicationContext.xml”);

i don’t understand this part– please can you explain it.

Basically we are instructing Spring here to load the application context file which is located in the classpath i.e inside your jar.

3 months, 3 weeks ago by James on Wordpress

ApplicationContext context = new ClassPathXmlApplicationContext

(”resources/applicationContext.xml”);

i don’t understand this part– please can you explain it.

3 months, 4 weeks ago by Styls on Wordpress

hey thanks for this example. i have let a lot from it.

3 months, 4 weeks ago by Styls on Wordpress

Thanx.. code is quite helpful to understand spring dependency injection

3 months, 4 weeks ago by arti on Wordpress

@mkyong

I still couldn’t get you. Could you please explain how to improve the lookup portion?

4 months ago by James on Wordpress

@James

I think what dendroot mention is about the following code

ApplicationContext context = new ClassPathXmlApplicationContext(”resources/applicationContext.xml”);

userService = (UserService) context.getBean(”userService”);

Your code is tight coupling to Spring, suggest to use Spring AOP to pass in your userService implementation class

4 months ago by mkyong on Wordpress

@mkyong

Hi Yong,

Yes Spring annotations help to remove much of the xml configurations, but, I like configuring using xml. That makes your application almost unaware of Spring.

4 months, 1 week ago by James on Wordpress

@dendroot

Hi dendroot,

The class “StandardUserServiceClient” doesn’t make use of Spring and shows how the code would be if the services are consumed directly.

4 months, 1 week ago by James on Wordpress

As I recon it just removes tight coupling from servic implementation classes, but adds tight coupling to spring… I think StandardUserServiceClient should get UserService through constructor or some setter method.

I think that application logic code should not be coupled to spring, but only application construction code.

4 months, 1 week ago by dendroot on Wordpress

Social comments and analytics for this post…

This post was mentioned on Twitter by solitarygeek: New at SolitaryGeek: Developing a simple java application with Spring – http://bit.ly/4brdIL…

4 months, 1 week ago by uberVU - social comments on Wordpress

Developing A Simple Java Application With Spring:http://www.solitarygeek.com/java...

4 months, 1 week ago by rainwebs on Friendfeed

[...] 3) 04 Nov 09 – Jame create a very simple java application with Spring. It’s a very good start for the Java’s Spring. Check it out Developing A Simple Java Application With Spring [...]

4 months, 1 week ago by Java bookmark links, Nov 2009 – Week1 | bookmark-link on Wordpress

hi, thanks for this simple and clean example for Spring to separate the DAO and service layer. May be can intro some Spring annotation in future

4 months, 1 week ago by mkyong on Wordpress

Developing A Simple Java Application With Spring…

This article explains how to get started with Spring by developing a simple java application….

4 months, 1 week ago by alldevnet.com on Wordpress

[...] This post was mentioned on Twitter by James, Amir. Amir said: A Simple #Java #Application With #Spring http://bit.ly/4brdIL [...]

4 months, 1 week ago by Tweets that mention Developing A Simple Java Application With Spring | SolitaryGeek -- Topsy.com on Wordpress

© uberVU Ltd. 2010

Terms of use
FEEDBACK