130
votes
1answer
21k views

Unsure if I understand TransactionAwarePersistenceManagerFactoryProxy

I am trying to use the org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy in my Spring project, but I am not sure how to use it or whether it's exactly what I am looking for. I ...
126
votes
8answers
49k views

Spring @Autowired usage

What are the pros and cons of using @Autowired in a class that will be wired up by Spring? Just to clarify, I'm talking specifically about the @Autowired annotation, not auto-wiring in XML. I ...
117
votes
13answers
79k views

When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?

I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. The code snippet below is what I'm doing. My question is, is this the accepted ...
98
votes
10answers
70k views

Spring @Transactional Annotation Best Practice

We are currently discussing the Best Practice for placing the @Transactional annotations in our code. Do you place the @Transactional in the DAO classes and/or their methods or is it better to ...
97
votes
9answers
64k views

Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]

Any ideas what could be the cause of this? Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] ...
94
votes
5answers
31k views

Difference between <context:annotation-config> vs <context:component-scan>

I'm learning Spring 3 and I don't seem to grasp the functionality behind <context:annotation-config> and <context:component-scan>. From what I've read they seem to handle different ...
91
votes
11answers
26k views

Why would I use Scala/Lift over Java/Spring?

I know this question is a bit open but I have been looking at Scala/Lift as an alternative to Java/Spring and I wonder what are the real advantages that Scala/Lift has over it. From my perspective and ...
87
votes
12answers
173k views

How can I inject a property value into a Spring Bean which was configured using annotations?

I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g. @Repository("personDao") public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao { // ...
82
votes
4answers
38k views

What's the difference between @Component, @Repository & @Service annotations in Spring?

Can @Component, @Repository & @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? In other words, if I have ...
72
votes
6answers
81k views

Type safety: Unchecked cast

In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"> <entry ...
70
votes
7answers
87k views

Getting Spring Application Context

Is there a way to statically/globally request a copy of the ApplicationContext in a Spring application? Assuming the main class starts up and initializes the application context, does it need to pass ...
68
votes
2answers
15k views

Shiro vs. SpringSecurity

I have currently evaluating Java based security frameworks, I am a Spring 3.0 user so it seemed that SpringSecurity would be the right Choice, but Spring security seems to suffer from excessive ...
64
votes
6answers
65k views

Spring - How to call a method after bean initialization is complete?

I have a use case where I need to call a (non-static) method in the bean only-once at the ApplicationContext load up. Is it ok, if I use MethodInvokingFactoryBean for this? Or we have a some better ...
61
votes
12answers
66k views

Why is Spring's ApplicationContext.getBean considered bad?

I asked a general Spring question: Auto-cast Spring Beans and had multiple people respond that calling Spring's ApplicationContext.getBean() should be avoided as much as possible. Why is that? How ...
60
votes
10answers
4k views

What exactly is Spring for?

I hear a lot about spring, people are saying all over the web that Spring is good framework for web development. But what exactly is it for? How can I use it for my Web-Java application any examples.

1 2 3 4 5 1024
15 30 50 per page