- 使用lombok成员方法输出日志
| @SpringBootApplication |
| @Slf4j |
| public class ReggieTakeOutApplication { |
| public static void main(String[] args) { |
| SpringApplication.run(ReggieTakeOutApplication.class, args); |
| log.info("程序运行开始"); |
| } |
| } |
- 配置mybatis和数据库不同命名规则映射关系
| mybatis-plus: |
| global-config: |
| db-config: |
| id-type: assign_id |
| configuration: |
| map-underscore-to-camel-case: true |
| log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
- 放行前端静态资源
| @Configuration |
| public class WebMvcConfig extends WebMvcConfigurationSupport { |
| |
| @Override |
| protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
| registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/"); |
| registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/"); |
| } |
| } |
- md5加密
参考:https://blog.csdn.net/qq_41437844/article/details/121120227
| password = DigestUtils.md5DigestAsHex(password.getBytes()); |
- 过滤器
| |
| @ServletComponentScan |
| |
| @WebFilter(filterName = "logCheckFilter", urlPatterns = "/*") |
| public class LogCheckFilter implements Filter { |
| |
| public AntPathMatcher pathMatcher = new AntPathMatcher(); |
| |
| @Override |
| public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
| |
| HttpServletRequest request = (HttpServletRequest) servletRequest; |
| HttpServletResponse response = (HttpServletResponse) servletResponse; |
| |
| String uri = request.getRequestURI(); |
| |
| String[] uris = new String[]{ |
| "/employee/login", |
| "/employee/logout", |
| "/backend/**", |
| "/front/**" |
| }; |
| |
| if (check(uris, uri)) { |
| filterChain.doFilter(request, response); |
| return; |
| } |
| |
| if (request.getSession().getAttribute("employee") != null) { |
| filterChain.doFilter(request, response); |
| return; |
| } |
| |
| response.getWriter().write(JSON.toJSONString(R.error("NOTLOGIN"))); |
| return; |
| |
| } |
| |
| public boolean check(String[] uris, String uri) { |
| |
| for (String u : uris) { |
| boolean match = pathMatcher.match(u, uri); |
| if (match) { |
| return true; |
| } |
| } |
| return false; |
| } |
| |
| } |
- No primary or single unique constructor found for interface java.util.List
参考:https://blog.csdn.net/weixin_43404791/article/details/105664692
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人