1.コントローラーコードを書く
@Autowired
private TeacherService teacherService;
@GetMapping
public List<Teacher> list(){
return teacherService.list(null);
}
2.SpringBoot構成クラスを作成します
Restスタイル
クエリ
useget add post modify put delete delete create config package under edu package、create MyBatisPlusConfig.java
package com.guli.edu.config;
@Configuration
@EnableTransactionManagement
@MapperScan("com.atguigu.eduservice.mapper")
public class MyBatisPlusConfig {
}
3.SQL実行パフォーマンス分析プラグインを構成します
/**
* SQL 执行性能分析插件
* 开发环境使用,线上不推荐。 maxTime 指的是 sql 最大执行时长
*/
@Bean
@Profile({"dev","test"})// 设置 dev test 环境开启
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
performanceInterceptor.setMaxTime(1000);//ms,超过此处设置的ms则sql不执行
performanceInterceptor.setFormat(true);
return performanceInterceptor;
}
4.SpringBootスタートアップクラスを作成します
スタートアップクラスEduApplication.javaを作成し、スタートアップクラスの作成場所に注意してください----最後に配置します
@SpringBootApplication
public class EduApplication {
public static void main(String[] args) {
SpringApplication.run(EduApplication.class, args);
}
}
5.スタートアップクラスを実行します
//访问地址 http://localhost:8001/eduService/edu-teacher/findAll
jsonデータを取得する
6.統合されたjson時間形式が返されました
デフォルトでは、json時間形式にはタイムゾーンがあり、普遍的な標準時間であり、時間
から8時間離れています。application.propertiesで設定します。
#返回json的全局时间格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
ただ