mybatis-plus
mp 测试逻辑删除是字段名不能设置为delete
maven工程同名工程引发依赖错误
mp 自动填充的配置类MetaObjectHandler要加component
使用@RequestBody传参数要是用@PostMapping
测试时包名不要是test
前端访问出错使用@CrossOrigin解决跨域
java.lang.NoClassDefFoundError: org/apache/velocity/context/Context 缺少模板引擎依赖
java.sql.SQLException: Access denied for user ‘’@’localhost’ (using password: YES) 配置文件中username和password配置错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception;
nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail !
Cause:java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc:mysql//localhost:3306/li?serverTimezone=GMT%2B8
URL 配置错误
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
没有读取到xml文件或xml文件中的方法名与mapper不一致 配置mapper-locations和aliases-package
1 | <dependency> |
2 | <groupId>com.baomidou</groupId> |
3 | <artifactId>mybatis-plus-boot-starter</artifactId> |
4 | <version>3.0.5</version> |
5 | </dependency> |
6 | <dependency> |
7 | <groupId>org.apache.velocity</groupId> |
8 | <artifactId>velocity-engine-core</artifactId> |
9 | <version>2.0</version> |
10 | </dependency> |
1 | spring.datasource.url=jdbc:mysql://localhost:3306/li?serverTimezone=GMT%2B8 |
2 | spring.datasource.username=root |
3 | spring.datasource.password=root |
4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
5 | |
6 | |
7 | |
8 | #配置mapper xml所在路径 xml在resources目录下时 |
9 | mybatis-plus.mapper-locations=classpath:/mapper/xml/*.xml |
10 | |
11 | #配置映射类所在包名 |
12 | mybatis-plus.type-aliases-package=com.example.mpdemo.entity |
13 | |
14 | #配置mapper xml所在路径 xml在src目录下时 |
15 | mybatis-plus.mapper-locations=classpath:com/example/mpdemo/mapper/xml/*.xml |
16 | 在pom.xml中加上 |
17 | <build> |
18 | <resources> |
19 | <resource> |
20 | <directory>src/main/java</directory> |
21 | <includes> |
22 | <include>**/*.xml</include> |
23 | </includes> |
24 | <filtering>false</filtering> |
25 | </resource> |
26 | </resources> |
27 | </build> |