This article refers to http://blog.csdn.net/chendaoqiu/article/details/46554139 ;
The construction process, and the problems encountered + mybatis automatically generated
Code download address: http://download.csdn.net/detail/u010634066/9641212
shushang-project
|—-pom.xml
|—-shuang-project-utils
|—-pom.xml
|—- shuang-project -domain
|—-pom.xml
|—- shuang-project -dao
|—-pom. xml
|—- shuang-project -service
|—-pom.xml
|—- shuang-project -web
|—-pom.xml
|—-shuang-project-web-backend
| —-Pom.xml
Create Project: Omit
Structure diagram:
I mainly explain the places that need to be paid attention to + mybatis is automatically generated
① Because it is multi-module; our configuration file is placed in shuang-project-web-backend
If you scan the configuration of mapper.xml
<property name="mapperLocations" value="classpath:com/mote/mapper/*.xml"></property>
Solution one:
classpath*:
classpath: will only look for files in your classpath;
After the above modification, the .xml file cannot be scanned;
Found out:
The .xml file must be placed under the resource folder; otherwise, the code in the above figure must be added to find it;
<!-- The following paragraph must be added because files other than resources cannot be scanned when scanning xml files in the field , unless you specify --> <!-- <build> <resources> <resource> <directory>src/ main/java</directory> </resource> </resources> </build>-->
Problem 2: The transaction does not take effect
Reason: When scanning the Controller, the services layer is also scanned; remove the Services or only scan the Controller
<!-- 把标记了@Controller注解的类转换为bean --> <!-- 下面一点要将services 注解的规避掉;不能扫描services 否则事务不生效--> <context:component-scan base-package="com.mote"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> </context:component-scan>
问题 三 :.NoClassDefFoundError: org/springframework/ui/freemarker/FreeMarkerConfigurationFactory
< dependency >
< groupId >org.springframework </ groupId >
< artifactId >spring-context-support </ artifactId >
< version >4.1.6.RELEASE </ version >
</ dependency >
自动生成
看项目里面的配置