<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3001203043106263545</id><updated>2024-09-08T07:11:47.733-07:00</updated><title type='text'>ganeshJava</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ganeshjavaspring.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ganeshjavaspring.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3001203043106263545.post-3416904437839691100</id><published>2012-03-30T05:30:00.003-07:00</published><updated>2012-03-30T05:30:32.913-07:00</updated><title type='text'>Spring Intergration to Eclipse IDE</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now that we have downloaded Spring Framework, we will see how to integrate it with Eclipse IDE.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Eclipse IDE by default is just a platform
 for development, which doesn’t carry all the JEE features required. It 
doesn’t ship with support for Spring Framework as you would know by now.
 So we will see how to integrate Spring Framework with Eclipse IDE using
 a standard plugin available called SpringIDE. Eclipse IDE is available 
in different releases, and these steps are almost similar to all of 
them. This post demonstrates&amp;nbsp;using Eclipse Galileo (Eclipse version 
3.5.0 release). If you have any doubts related to Eclipse IDE releases 
or its download / installation / configuration, refer to &lt;a href=&quot;http://tecnoesis.wordpress.com/category//eclipse-ide-tools-ides-2/&quot; target=&quot;_blank&quot;&gt;Eclipse IDE Installation &amp;amp; Configuration&lt;/a&gt; post.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
What is &lt;strong&gt;Spring IDE&lt;/strong&gt;?&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
SpringIDE provides a user interface for 
Spring configuration files, built as a set of plugins on the Eclipse 
platform. It is a set of free plugins for the Eclipse platform that 
helps in developing Spring Application. The IDE provides a wizard for 
creating Spring projects, and using the Graphical Editing Framework, 
displays graphs of all beans (objects) and relationships either within a
 single configuration file or within a set of configuration files. The 
files, or sets, are also validated as they are added / modified. There’s
 also support for Spring AOP, so pointcut expressions are validated in 
your Spring configuration.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Spring IDE (&lt;a href=&quot;http://www.springsource.com/products/springide&quot; target=&quot;_blank&quot;&gt;http://www.springsource.com/products/springide&lt;/a&gt;) is a product from Spring Source (&lt;a href=&quot;http://www.springsource.com/&quot; target=&quot;_blank&quot;&gt;http://www.springsource.com/&lt;/a&gt;). Refer to &lt;a href=&quot;http://tecnoesis.wordpress.com/category/spring-framework/1-spring-framework-primer/&quot; target=&quot;_blank&quot;&gt;Spring Primer &lt;/a&gt;for details.&amp;nbsp;Latest SpringIDE version avaiable is&amp;nbsp;2.0.3.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Follow the steps below:&amp;nbsp;&lt;span id=&quot;more-1304&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Once Eclipse is up and running, use the Eclipse Software Update wizard either by navigating to &lt;strong&gt;Help-&amp;gt;Install New Software&lt;/strong&gt; (Eclipse 3.5 onwards) or &lt;strong&gt;Help-&amp;gt;Software Updates&lt;/strong&gt; (prior to&amp;nbsp;Eclispe 3.5 version)&amp;nbsp;as shown below:&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/install-new-software.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1307&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/install-new-software.jpg?w=600&quot; title=&quot;install new software&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;or&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/software-updates.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1308&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/software-updates.jpg?w=600&quot; title=&quot;software updates&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;Click on the ‘Install New Software’ shown above (Eclipse 3.5 
onwards) or&amp;nbsp;”Add Site” button (prior to&amp;nbsp;Eclispe 3.5 version) and enter “&lt;a href=&quot;http://springide.org/updatesite&quot; target=&quot;_blank&quot;&gt;http://springide.org/updatesite&lt;/a&gt;“&amp;nbsp; or “&lt;a href=&quot;http://springide.org/updatesite/site.xml&quot; target=&quot;_blank&quot;&gt;http://springide.org/updatesite/site.xml&lt;/a&gt;” in the Available Software / Add Site wizard respectively as shown below:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;&lt;img alt=&quot;&quot; class=&quot;aligncenter&quot; height=&quot;365&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/install-new-software2.jpg?w=480&amp;amp;h=365&quot; title=&quot;install new software&quot; width=&quot;480&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
or&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;aligncenter&quot; height=&quot;164&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/add-site.jpg?w=418&amp;amp;h=164&quot; title=&quot;add site&quot; width=&quot;418&quot; /&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;For Eclipse versions 3.5 and above, click on Add button shown and 
then you will get the Add Site wizard. Enter the&amp;nbsp;name as Spring IDE or 
likewise for your reference later and click ok as shown below:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/spring-ide.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1313&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/spring-ide.jpg?w=600&quot; title=&quot;spring ide&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Select all the Spring IDE features and 
click Next or&amp;nbsp;Install for Eclipse 3.5 version onwards and Eclipse prior 
to this version respectively as shown below:&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/select-all-3-5.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1314&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/select-all-3-5.jpg?w=600&quot; title=&quot;select all 3.5&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;or&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/select-all-bfore-3-5.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1315&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/select-all-bfore-3-5.jpg?w=600&quot; title=&quot;select all bfore 3.5&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;In case you don’t get any error by now, 
you will be presented with a License Agreement wizard. Select ‘I Accept 
the terms of the license agreement’ and click ‘Finish’. By doing this, 
Spring IDE plugin should be installed and integrated in your Eclipse IDE
 successfully as shown below:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/license-agreement.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1317&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/license-agreement.jpg?w=600&quot; title=&quot;license agreement&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #ff6600;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;Restart Eclipse IDE as prompted&amp;nbsp;and you should be ready to use Spring IDE:&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;aligncenter&quot; height=&quot;122&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/apply-changes1.jpg?w=418&amp;amp;h=122&quot; title=&quot;apply changes&quot; width=&quot;418&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #ff6600;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
After Eclipse restarts, we need to 
verify whether the plugin got installed successfully. We will do this by
 first&amp;nbsp;choosing the Windows menu and the Preferences option of Eclipse.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;&lt;img alt=&quot;&quot; class=&quot;aligncenter&quot; height=&quot;300&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/windows-menu.jpg?w=201&amp;amp;h=300&quot; title=&quot;windows-menu&quot; width=&quot;201&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We can then see Spring option in the 
left hand side item nodes in the preferences dialog. Choose the Spring 
option and it will expand to show three sub items.&lt;br /&gt;
&amp;nbsp;- AOP Support&lt;br /&gt;
-&amp;nbsp; Beans Support&lt;br /&gt;
&amp;nbsp;- Web Flow Support&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/windows-preference.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1412&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/windows-preference.jpg?w=600&quot; title=&quot;windows-preference&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This confirms that our Spring IDE plugin has been installed successfully in Eclipse.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #ff6600;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #ff6600;&quot;&gt;Troubleshooting Installation &amp;amp; Integration:&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If you have any problems while installing
 as per above steps and get any error message in Eclipse IDE, read 
through the error message and don’t hesitate to uncheck that perticular 
plugin in the list where you have a problem (provided its optional). You
 can always install the plugin manually anytime again.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
For example:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
When you click on Next / Install after chosing the plugins you want to install, you might get an error message saying:&lt;/div&gt;
&lt;blockquote&gt;

&lt;div style=&quot;text-align: justify;&quot;&gt;
Cannot complete the install because one 
or more required items could not be found.&amp;nbsp;&amp;nbsp;Software being installed: 
Spring IDE AJDT Integration (optional) 2.2.8.200911091054-RELEASE&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this case, as AJDT (AspectJ 
Development Tools)&amp;nbsp;integration plugin is an optional update and if you 
have trouble installing it while updating the entire Spring Framework 
plugin, you can uncheck this plugin from the displayed list and continue
 to install other updates.&amp;nbsp;&amp;nbsp;You can always install the plugin manually 
anytime again.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://tecnoesis.files.wordpress.com/2009/11/troubleshoot.jpg&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-full wp-image-1316&quot; height=&quot;244&quot; src=&quot;http://tecnoesis.files.wordpress.com/2009/11/troubleshoot.jpg?w=600&amp;amp;h=244&quot; title=&quot;troubleshoot&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
After doing so, and clicking on ‘Next’, 
you should do away with the error message and be presented with the 
License Agreement wizard upon selecting which your installation should 
be complete.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ganeshjavaspring.blogspot.com/feeds/3416904437839691100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/spring-intergration-to-eclipse-ide.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/3416904437839691100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/3416904437839691100'/><link rel='alternate' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/spring-intergration-to-eclipse-ide.html' title='Spring Intergration to Eclipse IDE'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3001203043106263545.post-3753105234043839080</id><published>2012-03-28T00:16:00.000-07:00</published><updated>2012-03-28T00:16:01.145-07:00</updated><title type='text'>Annotation based configuration in Spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;color: #674ea7;&quot;&gt;

It is now possible to configure Spring&#39;s dependency injection with annotations. This means that 

annotations can be used in Spring to mark fields, methods and classes that need dependency 

injection. Spring also supports auto-wiring of the bean dependencies, that is, resolving the 

collaborating beans by inspecting the contents of the BeanFactory. Now there are annotations that 

can be used to indicate fields that are to be auto-wired. Furthermore, auto-detection of 

annotated components in the classpath is also supported now. When these capabilities are 

combined, the amount of configuration and dependency mapping in the Spring configuration files is 

reduced drastically.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

According to the Spring development team, the core theme of Spring 2.5 that was released in 

October 2007 is to provide comprehensive support for configuration annotations in application 

components. Annotation support was first announced in Spring 2.0, and has been significantly 

enhanced in Spring 2.5. It introduces support for a complete set of configuration annotations.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

I&#39;ll briefly discuss the annotation-driven configuration and auto-detection support in Spring 2.5 

with the help of a simple tutorial.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
What you need before you start
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

You need the following software to try out the tutorial.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
&lt;a href=&quot;http://www.java.net/external?url=http://java.sun.com/javase/downloads/index_jdk5.jsp&quot;&gt;Java 5.0&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.java.net/external?url=http://www.springframework.org/download&quot;&gt;Spring Framework 2.5&lt;/a&gt;
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;


You also need the following jars in your classpath. These are available with the Spring 

distribution.

&lt;/div&gt;
&lt;ul style=&quot;color: #674ea7;&quot;&gt;
&lt;li&gt;spring.jar&lt;/li&gt;
&lt;li&gt;asm-2.2.3.jar&lt;/li&gt;
&lt;li&gt;asm-commons-2.2.3.jar&lt;/li&gt;
&lt;li&gt;aspectjweaver.jar&lt;/li&gt;
&lt;li&gt;aspectjrt.jar&lt;/li&gt;
&lt;li&gt;hsqldb.jar&lt;/li&gt;
&lt;li&gt;commons-logging.jar&lt;/li&gt;
&lt;li&gt;log4j-1.2.14.jar&lt;/li&gt;
&lt;li&gt;junit-4.4.jar&lt;/li&gt;
&lt;li&gt;spring-test.jar&lt;/li&gt;
&lt;li&gt;common-annotations.jar(This is not required if Java 6.0 or later is used)&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;

&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
Adding the classes and interfaces for the example
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The example is just a simple service that returns a different message when an employee is hired 

or fired. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Let me start with the EmployeeService interface. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;


&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;package emptest;

public interface EmployeeService {
 String hire(String name);

 String fire(String name);
}

&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;


&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Here is a simple class that implements this interface.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@Service
public class EmployeeServiceImpl implements EmployeeService {
 @Autowired
 private EmployeeDao employeeDao;

 public String hire(String name) {
  String message = employeeDao.getMessage(&quot;Hire&quot;);
  return name + &quot;, &quot; + message;
 }

 public String fire(String name) {
  String message = employeeDao.getMessage(&quot;Fire&quot;);
  return name + &quot;, &quot; + message;
 }

 public void setEmployeeDao(EmployeeDao employeeDao) {
  this.employeeDao = employeeDao;
 }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;Stereotype Annotations&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Classes marked with stereotype annotations are candidates for auto-detection by Spring when using 

annotation-based configuration and classpath scanning. The @Component annotation is the main 

stereotype that indicates that an annotated class is a &quot;component&quot;. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The @Service stereotype annotation used to decorate the EmployeeServiceImpl class is a 

specialized form of the @Component annotation. It is appropriate to annotate the service-layer 

classes with @Service to facilitate processing by tools or anticipating any future 

service-specific capabilities that may be added to this annotation. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The @Repository annotation is yet another stereotype that was introduced
 in Spring 2.0 itself. 

This annotation is used to indicate that a class functions as a 
repository (the EmployeeDAOImpl below demonstrates the use) and needs to
 have exception translation applied transparently on it. The benefit of 
exception translation is that the service layer only has to deal with 
exceptions from Spring&#39;s DataAccessException hierarchy, even when using 
plain JPA in the DAO classes. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;@autowired&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Another annotation used in EmployeeServiceImpl is @autowired . This is used to autowire the 

dependency of the EmployeeServiceImpl on the EmployeeDao . Here is the EmployeeDao interface.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;/div&gt;
&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;public interface EmployeeDao {
    String getMessage(String messageKey);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;
&lt;/span&gt;


&lt;div style=&quot;color: #674ea7;&quot;&gt;

The implementing class EmployeeDaoImpl uses the @Repository annotation.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;/div&gt;
&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@Repository
public class EmployeeDaoImpl implements EmployeeDao {

 private SimpleJdbcTemplate jdbcTemplate;

 public String getMessage(String messageKey) {
  return jdbcTemplate.queryForObject(
    &quot;select message from messages where messagekey = ?&quot;,
    String.class, messageKey);
 }

 @Autowired
 public void createTemplate(DataSource dataSource) {
  this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
 }
}

&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;
&lt;/span&gt;


&lt;div style=&quot;color: #674ea7;&quot;&gt;

Here again, the DataSource implementation is autowired to the argument taken by the method that 

creates the SimpleJdbcTemplate object.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;Simplified Configuration&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The components discovered by classpath scanning are turned into Spring bean definitions, not 

requiring explicit configuration for each such bean. So the Spring configuration xml file is very 

simple.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
 xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
 xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
 xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
           &lt;a href=&quot;http://www.java.net/external?url=http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot; title=&quot;http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&lt;/a&gt;
           &lt;a href=&quot;http://www.java.net/external?url=http://www.springframework.org/schema/aop&quot; title=&quot;http://www.springframework.org/schema/aop&quot;&gt;http://www.springframework.org/schema/aop&lt;/a&gt;
           &lt;a href=&quot;http://www.java.net/external?url=http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&quot; title=&quot;http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&quot;&gt;http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&lt;/a&gt;
           &lt;a href=&quot;http://www.java.net/external?url=http://www.springframework.org/schema/context&quot; title=&quot;http://www.springframework.org/schema/context&quot;&gt;http://www.springframework.org/schema/context&lt;/a&gt;
           http://www.springframework.org/schema/context/spring-context-2.5.xsd&quot;&amp;gt;
 &amp;lt;context:annotation-config /&amp;gt;
 &amp;lt;context:component-scan base-package=&quot;emptest&quot; /&amp;gt;
 &amp;lt;aop:aspectj-autoproxy /&amp;gt;

 &amp;lt;context:property-placeholder location=&quot;classpath:jdbc.properties&quot; /&amp;gt;

 &amp;lt;bean id=&quot;dmdataSource&quot;
  class=&quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot;&amp;gt;
  &amp;lt;property name=&quot;driverClassName&quot; value=&quot;${jdbc.driver}&quot; /&amp;gt;
  &amp;lt;property name=&quot;url&quot; value=&quot;${jdbc.url}&quot; /&amp;gt;
  &amp;lt;property name=&quot;username&quot; value=&quot;${jdbc.username}&quot; /&amp;gt;
  &amp;lt;property name=&quot;password&quot; value=&quot;${jdbc.password}&quot; /&amp;gt;
 &amp;lt;/bean&amp;gt;
  
&amp;lt;/beans&amp;gt;

&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Now let me explain the new configurations in the above Spring context file. The 

&amp;lt;context:annotation-config /&amp;gt; element is used to automatically register all of Spring&#39;s 

standard post-processors for annotation-based configuration. The &amp;lt;context:component-scan 

annotation&amp;gt; element is used to enable autodetection of the stereotyped classes in the package 

emptest . Since the AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor 

are both included implicitly when using the component-scan element, the 

&amp;lt;context:annotation-config/&amp;gt; element can be omitted.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The properties for the data source are taken from the jdbc.properties file in the classpath. The 

property placeholders are configured with the &amp;lt;context:property-placeholder&amp;gt; element.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The &amp;lt;aop:aspectj-autoproxy/&amp;gt; element is used to enable @AspectJ support in Spring. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
@Aspect
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The @Aspect annotation on a class marks it as an aspect along with @Pointcut definitions and 

advice (@Before, @After, @Around) as demonstrated in the TraceLogger class defintion below. The 

PointCut is applied for all methods in the EmployeeServiceImpl class. The @Before annotation 

indicates that the log() method in the TraceLogger is to be invoked by Spring AOP prior to 

calling any method in EmployeeServiceImpl.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@Component
@Aspect
public class TraceLogger {
 private static final Logger LOG = Logger.getLogger(TraceLogger.class);

 @Pointcut(&quot;execution(* emptest.EmployeeServiceImpl.*(..))&quot;)
 public void empTrace() {
 }

 @Before(&quot;empTrace()&quot;)
 public void log(JoinPoint joinPoint) {
  LOG.info(&quot;Before calling &quot; + joinPoint.getSignature().getName()
    + &quot; with argument &quot; + joinPoint.getArgs()[0]);
 }

}
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Since there is no definition provided for TraceLogger in the Spring context file, it is marked 

for auto-detection from the classpath using the @Component annotation.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
@Qualifier and @Resource
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Suppose there is one more DataSource configuration in the spring context file as follows.


&lt;/div&gt;
&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;&amp;lt;bean id=&quot;jndidataSource&quot;
 class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;jndiName&quot; value=&quot;jdbc/test&quot; /&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Since auto-detection is enabled, auto-wiring will fail since both data source beans are equally 

eligible candidates for wiring. It is possible to achieve by-name auto-wiring by providing a bean 

name within the @Qualifier annotation as follows. The below method injects the DataSource 

implementation by specifying the name â€œdmdataSourceâ€. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@Autowired
public void createTemplate(@Qualifier(&quot;dmdataSource&quot;) DataSource dataSource) {
  this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
JSR-250 Annotations
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Spring also provides support for Java EE 5 Common Annotations (JSR-250). The supported 

annotations are @Resource, @PostConstruct and @PreDestroy. The @Resource annotation is also 

supported by Spring for autowiring as shown in the below code, the bean name to be autowired is 

passed.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@Resource(name = &quot;dmdataSource&quot;)
public void createTemplate(DataSource dataSource) {
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

The JSR-250 lifecycle annotations @PostConstruct and @PreDestroy can be used to specify 

initialization callbacks and destruction callbacks respectively. To demonstrate the use of these, 

Iâ€™m adding the following code to the EmployeeDaoImpl class.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;@PostConstruct
public void initialize() {
 jdbcTemplate.update(&quot;create table messages (messagekey varchar(20), message 

varchar(100))&quot;);
 jdbcTemplate.update(&quot;insert into messages (messagekey, message) values (&#39;Hire&#39;, Congrats! 

You are hired&#39;)&quot;);
 jdbcTemplate.update(&quot;insert into messages (messagekey, message) values (&#39;Fire&#39;, &#39;Sorry! 

You are fired&#39;)&quot;);
}

@PreDestroy
public void remove() {
 jdbcTemplate.update(&quot;drop table messages&quot;);
}

&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

&lt;b&gt;
Unit Testing
&lt;/b&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Before testing the service implementation, I provided the database configuration details in the 

jdbc.properties file as follows.
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;pre class=&quot;listing&quot; style=&quot;color: #674ea7;&quot;&gt;jdbc.driver=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:mem:blog
jdbc.username=sa
jdbc.password=
&lt;/pre&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div style=&quot;color: #674ea7;&quot;&gt;

Here is the class I wrote for unit testing. 
&lt;/div&gt;
&lt;span style=&quot;color: #674ea7;&quot;&gt;

&lt;/span&gt;&lt;div class=&quot;listing cpp&quot; style=&quot;color: #674ea7;&quot;&gt;
&lt;pre class=&quot;listing&quot;&gt;public class EmployeeServiceImplTests extends
  AbstractDependencyInjectionSpringContextTests {
 @Autowired
 private EmployeeService employeeService;&lt;span style=&quot;background-color: #999999;&quot;&gt;&lt;/span&gt;

 @Override
 protected String[] getConfigLocations() {
  return new String[] { &quot;context.xml&quot; };
 }

 public void testHire() {
  String name = &quot;Tom&quot;;
  String message = employeeService.hire(name);
  assertEquals(name + &quot;, &quot; + &quot;Congrats! You are hired&quot;, message);
 }

 public void testGermanWelcome() {
  String name = &quot;Jim&quot;;
  String message = employeeService.fire(name);
  assertEquals(name + &quot;, &quot; + &quot;Sorry! You are fired&quot;, message);
 }

 public void setEmployeeService(EmployeeService employeeService) {
  this.employeeService = employeeService;
 }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ganeshjavaspring.blogspot.com/feeds/3753105234043839080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/annotation-based-configuration-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/3753105234043839080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/3753105234043839080'/><link rel='alternate' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/annotation-based-configuration-in.html' title='Annotation based configuration in Spring'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3001203043106263545.post-5857718639255101596</id><published>2012-03-27T23:45:00.000-07:00</published><updated>2012-03-27T23:45:06.168-07:00</updated><title type='text'>The @transactional Annotation In Spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The other day, on my current project, I had a situation where I needed to change some transaction parameters on a &lt;a href=&quot;http://en.wikipedia.org/wiki/Data_Access_Object&quot;&gt;DAO&lt;/a&gt; to start a new transaction whenever methods on that DAO were invoked.&lt;br /&gt;
&lt;br /&gt;
The application architecture is based on a generic DAO interface with standard &lt;a href=&quot;http://en.wikipedia.org/wiki/Create,_read,_update_and_delete&quot;&gt;CRUD&lt;/a&gt;  operations implemented by a GenericDao. All DAOs have defined their own  interface extending the generic DAO and likewise the implementation is  extending the GenericDao:&lt;br /&gt;
&lt;br /&gt;
The goal was to have all methods, defined on either the GenericDao or  the (in this example) UserDaoImpl , to start a new transaction when  invoked.&lt;br /&gt;
&lt;br /&gt;
The GenericDao is annotated with &lt;a href=&quot;http://springframework.org/&quot;&gt;Springs&lt;/a&gt; &lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/annotation/Transactional.html&quot;&gt;@Transactional&lt;/a&gt; annotation with default parameters (&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/annotation/Propagation.html#REQUIRED&quot;&gt;Propagation.REQUIRED&lt;/a&gt;) which will be inherited to all extending DAOs.&lt;br /&gt;
&lt;br /&gt;
My first attempt to achieve  my goal was to annotate the UserDaoImpl with @Transactional(propagation=&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/annotation/Propagation.html#REQUIRES_NEW&quot;&gt;Propagation.REQUIRED_NEW&lt;/a&gt;).  Well, this did not have the effect I had hoped for. Now all methods  declared on the UserDaoImpl will start a new transaction, but methods on  the GenericDao will not and if I removed the annotation on the  GenericDao and defined it on all DAOs then invoked methods on the  GenericDao will not be transactional at all.&lt;br /&gt;
&lt;br /&gt;
This forced me to investigate how Spring handles the @Transactional annotation and it all comes down to how the method &lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.html#getTransactionAttribute%28java.lang.reflect.Method,%20java.lang.Class%29&quot;&gt;getTransactionAttribute(Method method, Class targetClass)&lt;/a&gt; on the class &lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.html&quot;&gt;AbstractFallbackTransactionAttributeSource&lt;/a&gt; works.&lt;br /&gt;
&lt;br /&gt;
I&#39;ll try to explain:&lt;br /&gt;
- the method will be invoked where parameter method is Dao#update and targetClass is UserDaoImpl.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;The method is from the Dao interface so firstly the actual implementation will be found = GenericDao#update.&lt;/li&gt;
&lt;li&gt;This will be the first place to look for the annotation - on the method on the declaring class. Not the case here.&lt;/li&gt;
&lt;li&gt;If  not on the method then look if the declaring class has defined the  annotation. Yep - in this case the GenericDao has defined the annotation  for default behavior for all extending DAOs, which means that a new  transaction will not be started for invoked methods defined on  GenericDao. If I override the method in UserDaoImpl and simply call  super I would get the expected behavior, but I do not find this as a  convenient solution.&lt;/li&gt;
&lt;li&gt;If the target class is a interface and the annotation is not yet present then the interface method and class is searched.&lt;/li&gt;
&lt;/ol&gt;This  seems like a good strategy to search for the annotation, but maybe you  could argue that if the annotation is present directly on the  targetClass (UserDaoImpl) then it should be used  in advance of the  annotation defined on the actual declaring class of the method in  action. You could see this as a way to overwrite the annotaton on the  super class.&lt;br /&gt;
&lt;br /&gt;
In the above list this could be number 2.5 just  after searching on the method then look at the targetClass before the  declaring class... (if they differ at all...) What do you think? Is this  a reasonable suggestion?&lt;br /&gt;
&lt;br /&gt;
Well, back to my problem. My solution  was of course keep the @Transactional on the GenericDao and remove it  from UserDaoImpl and then create a new service in the service layer  annotated with  @Transactional(propagation=Propagation.REQUIRES_NEW) and  actually I am more happy with this solution as it keeps the Dao  operations simple and atomic.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ganeshjavaspring.blogspot.com/feeds/5857718639255101596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/transactional-annotation-in-spring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/5857718639255101596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3001203043106263545/posts/default/5857718639255101596'/><link rel='alternate' type='text/html' href='http://ganeshjavaspring.blogspot.com/2012/03/transactional-annotation-in-spring.html' title='The @transactional Annotation In Spring'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>