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.
分享到:
相关推荐
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, ...
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)
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 ...
9. **User Interaction**: A keyboard interface allows users to set and modify the target humidity values, providing user customization and control. 10. **Overall System Integration**: All these ...
3.5.6 Connecting the SLD to CTS+ to Facilitate the Export and Import of SLD Data 3.6 Exercise: Configuring the System Landscape Directory 3.6.1 Exercise Description 3.6.2 Exercise Solution ...
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 ...
The flow rate is automatically set in order to maintain the nominal fuel utilization. Observe the DC bus voltage (Scope2) which is very well regulated by the converter. The peak voltage of 122Vdc at ...
4. **Answer Submission**: Students submit their code snippets or answers to the questions within a specified time frame, with the system automatically evaluating the correctness. 5. **Scoring and ...
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...