Finally, those of you who don’t want to spend lots of time in wiring down each and every interface bean, can use the MapperScannerConfigurer which allows you to automatically scan the directories and mark the mapper interfaces.
1. Define the MapperScannerConfigurer and mark the basePackage.
1 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
2 <property name="basePackage" value="org.mybatis.spring.sample.mapper" />
3 </bean>
2. The mapper interfaces which are referred in the service classes need to be autowired, since their references will no longer be present in the mapper-config.xml
3. Finally, sqlSessionFactory also needs to be configured(
contrary to the Mybatis manual), else the mappers will not work and will throw this exception :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘employeeMapperInterface’ defined in file [C:\anirban\Work_Ani\SpringIntegration\WebRoot\WEB-INF\classes\com\mybatis\dao\EmployeeMapperInterface.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
must added property :
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
Note: There was an issue with PropertyPlaceHolderConfigurer not working when used in conjunction with mybatis-spring-3.1.0. Its resolved by replacing with mybatis-spring-3.1.1 bundle.
Thats it folks for the Mybatis stuff for this session. Now, lets jump to the Spring related changes . Recall that ,
Request –> Spring MVC controller –> accesses Service facade –> accesses the DAO xml/interface.
分享到:
相关推荐
A basic requirement for ...the CASNl design principles, user interface, and some example applications. The performance of the ED library and generated CASNl code is also measured and discussed.
An add-in to automatically increment the PrivateBuild field in your applications resource file.(34KB)
SwooleFor监控你的 Swoole 程序文件变化并自动重启服务器 - 适用于开发Monitor for any changes in your swoole application and automatically restart the server - perfect for developmentSwooleFor 的定位就...
Android User Interface Design details each step of the design and development process and contains extensive downloadable sample code, including complete finished apps. Learn how Android has evolved ...
(Input the hour, minute and order of a day, and automatically read the precise ephemeris file. Neville interpolation has the highest accuracy among the given order data, so it will automatically ...
Rcpp attributes provide a high-level syntax for declaring C++ functions as callable from R and automatically generating the code required to invoke them. Attributes are intended to facilitate both ...
IDA can automatically analyze the millions of opcodes that make up an executable and present you with a disassembly. But at that point, your work is just beginning. With The IDA Pro Book, you'll ...
Step 3: click the 'MSBTD method'to run MSBTD and click the 'Tikhonov method'to run the Tikhonov for comparison (visually denoised results will be automatically shown in the top left and the PSNR ...
If you are experiencing problems with the Universal Plug and Play service, your computer might not be able to automatically detect the presence of other networked devices, such as PCs, printers, ...
How to run tasks in the background and update the user interface asynchronously How to build plug-ins, features and update sites with Maven Tycho and automate user interface tests with SWTBot How ...
maximenu_ck参数设置插件 Multicolumns and multirows Responsive design themes Logo can be added in the ...Compatibility with Joomshopping, can automatically list the product categories (needs the patch)
The new version 5 is packed with new themes and the MVVM architecture that allows you to connect the model layer to the view and automatically update the model when the view is modified and vice ...
Develop apps that automatically apply the best layouts for different devices by using designated directories Socialize in the digital word by connecting your app to social media Make your apps ...
After the initial setup the password for SSH and VNC generated automatically. The password can be changed through "Properties -> User password" or standard OS tools (passwd, vncpasswd). The app is ...
Web mining is usually defined as the use of data mining techniques to automatically discover and extract information from web documents and services. Web mining is the application of data mining ...
Set up each test to automatically deal with AJAX and jQuery Remove test instabilities by blocking third-party services Deal with data uncertainties by using fixtures, JSON APIs, and API stubbing ...
The DM9000A is a fully integrated and cost-effective low pin count single chip Fast Ethernet controller with a general processor interface, a 10/100M PHY and 4K Dword SRAM. It is designed with low ...
The book teaches using real-world examples and shows you how to use ANTLR to build such things as a data file reader, a JSON to XML translator, an R parser, and a Java class->interface extractor....
On the "View" ribbon you can now choose between a Single Document Interface (SDI) or Multiple Document Interface (MDI - the same as in PL/SQL Developer 11.0 and earlier). In SDI mode you always see ...
automatically informs firewall and dynamically alters the rules of firewall once an attack is found; on the other hand, firewall loads dynamic rules to hold up the intrusion, controls the data traffic...