1.在主项目下创建module发现java,resources,test目录颜色没有改变

IDEA常见问题 - 图1IDEA常见问题 - 图2

2.子工程maven依赖交给父工程托管

需要托管的依赖加上<dependencyManagement> 标签,如此子项目中的版本不需要写明直接使用父工程提供的版本
IDEA常见问题 - 图3
要在子pom中声明父工程的地址
IDEA常见问题 - 图4
父工程中也要写明托管的子工程
IDEA常见问题 - 图5

3.项目过大导致单元测试卡死

在pom.xml中添加

  1. <!--用于解决单元测试卡住的问题-->
  2. <dependency>
  3. <!-- this is needed or IntelliJ gives junit.jar or junit-platform-launcher:1.3.2 not found errors -->
  4. <groupId>org.junit.platform</groupId>
  5. <artifactId>junit-platform-launcher</artifactId>
  6. <scope>test</scope>
  7. </dependency>

4.mysql列名为关键字

为关键字时用`区分
https://blog.csdn.net/yang3290325/article/details/3349907

5.前后端跨域问题

前后端的协议,端口,http/https不同时就会出现403,
解决方法:
1.在后端controller层添加注解@CrossOrigin
IDEA常见问题 - 图6
2.nginx

6.修改mapper.xml文件后报错

IDEA常见问题 - 图7
原因:maven进行编译时,只会把Java文件夹和resources里面的配置文件进行加载。Java文件进行编译,其他类型文件不会进行加载
解决:

  1. 将xml文件放到resources里面,不建议
  2. 推荐方法:进行配置实现,通过配置让maven加载xml配置文件

第一个地方,在项目pom.xml中添加

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. </plugin>
  7. </plugins>
  8. <!--项目打包时将Java目录中的*.xml文件也进行打包-->
  9. <resources>
  10. <resource>
  11. <directory>src/main/java</directory>
  12. <includes>
  13. <include>**/*.xml</include>
  14. </includes>
  15. <filtering>false</filtering>
  16. </resource>
  17. </resources>
  18. </build>

第二个地方在springboot配置文件(application.yml)中添加
#配置mapper.xml文件路径 mybatis-plus.mapper-locations: classpath:com/guli/edu/mapper/xml/*.xml

7.启动项一直报错,result Type一直找不到

  1. 检查类路径是否有错
  2. 整个项目进行build
  3. 重启idea
  4. 重启电脑
  5. 修改项目名称,并更改路径

8.自动填充将gmtCreate(创建时间),gmtModified(更新时间)两个字段填充

handler中创建CommonMetaObjectHandler

  1. package com.online.edu.eduservice.handler;
  2. import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
  3. import org.apache.ibatis.reflection.MetaObject;
  4. import org.springframework.stereotype.Component;
  5. import java.util.Date;
  6. /**
  7. * @description:实现mp的自动填充功能,将gmtCreate,gmtModified两个字段填充
  8. * @author: yuqiong
  9. * @createDate: 2020/3/15
  10. * @version: 1.0
  11. */
  12. @Component
  13. public class CommonMetaObjectHandler implements MetaObjectHandler {
  14. @Override
  15. public void insertFill(MetaObject metaObject) {
  16. this.setFieldValByName("gmtCreate",new Date(),metaObject);
  17. this.setFieldValByName("gmtModified",new Date(),metaObject);
  18. }
  19. @Override
  20. public void updateFill(MetaObject metaObject) {
  21. this.setFieldValByName("gmtModified",new Date(),metaObject);
  22. }
  23. }

实体类添加注解

  1. @ApiModelProperty(value = "创建时间")
  2. @TableField(fill = FieldFill.INSERT)//自动填充标识
  3. private Date gmtCreate;
  4. @ApiModelProperty(value = "更新时间")
  5. @TableField(fill = FieldFill.INSERT_UPDATE)//自动填充标识
  6. private Date gmtModified;

9.运行 时出错: !invalid format: `命令行过长

https://blog.csdn.net/f641385712/article/details/106601324

10.中文乱码

image.png