项目中的问题
项目地址
https://github.com/Zephon-H/vue-ssm-traveller-manage
1、使用mybatis时,数据库中使用驼峰命名,到java中的命名无法自动转换
解决:
在spring配置文件中添加mybatis配置
1
2
3
4
5<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- 配置mybatis配置-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>配置mybatis-config.xml中的驼峰命名转换
1
2
3
4
5
6
7
8
9
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
2、使用jackson解析时,当请求中有日期时,解析错误
解决:
直接将@RequestBody中的对象转为map再进行提取
3、在使用pagehelper插件时,parent的pom.xml中导入了包,但还是报错ClassNotFoundExecption
解决:
在idea中,project structure->Artifacts->右侧的Available Elements中找到parent模块->右键->put into output root
4、使用AOP时,AOP不生效
解决:
在applicationContext.xml添加
1 | <context:component-scan base-package="com.zephon.aop"/> |
5、文件上传时报错Required request part 'file' is not present
解决:
配置文件上传解析器
在pom.xml中
1
2
3
4
5
6
7
8
9
10
11
12
13<!--文件上传-->
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>在applicationContext.xml中
1
2
3
4
5
6
7<!-- 文件上传的解析器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 编码格式 -->
<property name="defaultEncoding" value="UTF-8"/>
<!-- 配置上传文件的大小,以字节为单位;-1代表没有限制 -->
<property name="maxUploadSize" value="-1"/>
</bean>