springboot+mybatis项目实战记录

之前学习了springboot开发,做一下记录,方便后面自己回看。基本内容都来自网上,可能会存在错误和不足:

1.使用generatorconfig.xml 配置文件自动生成实体类、生成mapxml文件、生成mapxml对应client,也就是接口dao
参考:https://www.cnblogs.com/wangkeai/p/6934683.html
2.使用web模板Thymeleaf

Thymeleaf是Java服务端模板引擎,能够处理HTML,XML,Javascript,CSS和文本,主要目标是提供自然的、高度可维护性的模板。基于自然模板的概念,将逻辑注入模板文件中,且不影响其设计原型

pom.xml中引用:
<!--web 模板-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- 允许使用非严格的 HTML 语法 -->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>

参考:https://www.jianshu.com/p/7c27c50f24ec

   https://www.cnblogs.com/jpfss/p/11038481.html

3.配置文件application.properties
默认创建spring-boot项目后,会在resources目录下生成一个空的application.properties配置文件,springboot启动时加载该配置文件。
application.properties(或者application.yml)中包含系统属性、环境变量、命令参数这类信息。

4.注解学习

@Controller:标注Controller类,处理http请求
@RestController:标注Controller类,spring4新加注解,相当于@Controller+@ResponseBody
@ResponseBody:主要是为了使用http请求返回数据格式为json,正常情况下都是使用这个注解
@RequestMapping:配置url映射,可以作用于类上,也可以在方法上,可以指定value(路径内容),produces(内容格式),method(请求方式)
@Component:
@ConfigurationProperties:

原文地址:https://www.cnblogs.com/zyanrong/p/11799949.html