Tom Tucker
Tom Tucker

Reputation: 11916

Spring Pitfalls

As a relatively new comer to the Spring world, I figured it would be nice to have a community Wiki page that lists common pitfalls in Spring-based projects.

These include:

Upvotes: 2

Views: 866

Answers (4)

JohannesDienst
JohannesDienst

Reputation: 485

Mixing Annotation-based configuration with XML-based configuration. Happens to me all the time...

Upvotes: 2

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340993

  1. Calling public methods using this when inside a proxy-enriched bean. This is a recurring problem in StackOverflow, explained here.

  2. Injecting bean with prototype scope does not mean you'll have a new instance every time you use this bean. Explain lookup-method. Also: how to use session-scoped beans in singletons.

  3. Spring can be used outside of the web container. Example of ClassPathXmlApplicationContext.

  4. Proper usage of Spring testing support. Explain default transaction behavior.

Upvotes: 1

Aravind Yarram
Aravind Yarram

Reputation: 80192

Most abused and misunderstood concept: Not everything need to be injected.

Others:

  1. Performance problems when using lots of AOP request scoped beans (perf)

  2. Singleton beans are loaded differently in BeanFactory and ApplicationContext. A bean factory lazily loads all beans, deferring bean creation until the getBean() method is called. An application context loads all singleton beans upon context startup.

  3. Unified property management through Spring's new Environment abstraction in 3.1 rather than using PropertyPlaceholderConfigurer

  4. Other deprecated features

Upvotes: 3

Tom Tucker
Tom Tucker

Reputation: 11916

I'll start first. Use of DAO templates, such as JpaDaoSupport and JpaTemplate for JPA, is no longer recommended in Spring 3 in favour of direct use of JPA.

Upvotes: 0

Related Questions