写在前面
Swagger 2.8.0
Spring Boot 2.0.0.RELEASE
Shiro 1.4.0
Mybatis 1.3.1
填坑
踩坑一:
MyBatis xml文件中参数名选择
若UserMapper.java写法为
User findByUserId(int userId);
则在UserMapper.xml里参数名只能为arg0、arg1…
<select id="findByUserId" resultType="com.pojo.User">
SELECT * FROM user WHERE id=#{arg0}
</select>
想要改成
<select id="findByUserId" resultType="com.pojo.User">
SELECT * FROM user WHERE id=#{userId}
</select>
则UserMapper.java需要修改为
User findByUserId(@Param("userId") int userId);
踩坑二:
集成Shiro框架后,重定向导致前端页面布局错乱
//放行静态资源
filterChainDefinitionMap.put("/css/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/layui/**", "anon");
filterChainDefinitionMap.put("/pm/login", "anon");
把前端所有静态资源都免去认证
踩坑三:
集成Shiro + Swagger,Swagger页面无法查看接口
解决办法与上面类似
/**
* @Mark 在线接口文档路径
* @URL http://localhost:8080/swagger-ui.html
*/
filterChainDefinitionMap.put("/swagger-ui.html","anon");
filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/swagger/**","anon");
filterChainDefinitionMap.put("/webjars/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/**","anon");
filterChainDefinitionMap.put("/v2/**","anon");
踩坑四:
分模块,启动后报错:缺失文件
Application主程序添加自动扫包代码
@ComponentScan(basePackages = {"com.*"})
踩坑五:
动态数据源无法与MyBatis的xml对应起来
具体解决方案见《SpringBoot+MyBatis 动态数据源(含项目地址)》
最后说一个题外话:
就是IEDA在debugger的时候运行特别慢,那有可能是把断点打在方法上了,改成打在方法内部就好了。