Tag Archives: Spring Framework

Spring @MVC configuration without XML

XML is no longer hip. Actually, there is nothing as unhip as last year’s hip. That is until it becomes hip again 30 years later in failed irony. Honestly, if you’ve been programming Java EE since the 90s, you know full well how error prone XML config files can be. A glance at an EJB [...]

Posted in Spring MVC | Also tagged | 2 Responses

Spring 3, Hibernate JPA, Tomcat transactions

I tried to deploy a webapp that uses Spring 3, JPA with the Hibernate implementation and Tomcat. There are domain classes with a DAO layer which is called from the Service layer. The classes are annotated correctly. All of the unit tests work. Actually the whole webapp works deployed on other web containers : but [...]

Posted in Hibernate, JPA, Spring Framework | Also tagged , | Leave a comment

Spring component scan and StoredProcedure

Let’s say you wrap stored procedures with Spring’s StoredProcedure class like this: 1 2 3 4 @Repository public class SPGetWhatever extends StoredProcedure { @Autowired public SPGetWhatever (DataSource dataSource)etc. That @Repository annotation, like @Component and @Service, allows you to tell Spring to scan the classpath and instantiate them without you having to write a bean element [...]

Posted in Spring Framework | Tagged | Leave a comment

Spring and Transactions

I’ve been taking a legacy codebase, putting testing in place and refactoring. For DB access I retrofitted the persistence classes to be injected via Spring with a DataSource instead of looking them up via JNDI. IN my Spring context I defined a PlatformTransactionManager. 1 2 3 4 5 6 7 8 9 10 <bean id="dataSource" [...]

Posted in DB, Spring Framework, Testing | Also tagged | Leave a comment

JUnit4, Selenium and Spring test context

In a previous post I wrote about using JUnit4 with Selenium. So how about injecting your JUnit run listener via Spring? My first attempt modified my runner to be a subclass of SpringJUnit4ClassRunner Then I created the usual XML spring config file but named it after my test class name. So for FooTests I created [...]

Posted in Selenium, Spring Framework, Testing | Also tagged , | 3 Responses

Inversion of Control and Dependency Injection

Let’s take a look at an EJB 2.1 client. We have a stateless session bean that performs simple calculations. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [...]

Posted in EJB, Spring Framework | Also tagged , , | Leave a comment