###1、Mybatis映射
xx.xml的mybatis映射不会自动打包到target需要在build中导入配置
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
includes>
resource>
resources>
###2、maven一些常用的配置包
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<scope>runtimescope>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<optional>trueoptional>
dependency>
<dependency>
<groupId>org.mybatis.spring.bootgroupId>
<artifactId>mybatis-spring-boot-starterartifactId>
<version>2.2.2version>
dependency>
<dependency>
<groupId>org.mybatis.generatorgroupId>
<artifactId>mybatis-generator-coreartifactId>
<version>1.4.0version>
dependency>
###3、application配置
spring.datasource.url=jdbc:mysql://xxxxxxxx:3306/xxxx?serverTimezone=GMT%2B8
spring.datasource.username=xxxxx
spring.datasource.password=xxxxxx
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
4、当有多个mapper文件时
在spring boot启动文件中加入
@MapperScan("com.ant.demo.Mapper")//当不止一个mapper文件时会找不到mapper文件需要映射
###5、controller中加入跨域
@CrossOrigin
6、controller标记
@RestController//标记此层为controller
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)