Spring Boot+Gradle+ MyBatis-Plus3.x搭建企業(yè)級(jí)的后臺(tái)分離框架
來(lái)源:toutiao.com/i6861456496740270604
1、技術(shù)選型
解析器:FastJSON 開發(fā)工具:JDK1.8 、Gradle、IDEA 技術(shù)框架:SpringBoot 2.1.5.RELEASE ORM技術(shù):MyBatisPlus3.1.2 數(shù)據(jù)庫(kù):MySQL8.0.21 Apache 工具:HttpClient、Lang3 Git代碼版本控制 Web服務(wù)器:undertow hutool 國(guó)產(chǎn)工具類包 lombok 簡(jiǎn)化代碼工具 -druid 數(shù)據(jù)庫(kù)連接池框架
國(guó)慶節(jié),倒計(jì)時(shí)最后2天,限量秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
2、Spring Boot 發(fā)展路線簡(jiǎn)要描述
隨著動(dòng)態(tài)語(yǔ)言的流行 (Ruby、Groovy、Scala、Node.js),Java 的開發(fā)顯得格外的笨重:繁多的配置、低下的開發(fā)效率、復(fù)雜的部署流程以及第三方技術(shù)集成難度大。 在上述環(huán)境下,Spring Boot 應(yīng)運(yùn)而生。它使用“習(xí)慣優(yōu)于配置”(項(xiàng)目中存在大量的配置,此外還內(nèi)置了一個(gè)習(xí)慣性的配置,讓你無(wú)需手動(dòng)進(jìn)行配置)的理念讓你的項(xiàng)目快速的運(yùn)行起來(lái)。使用 Spring Boot 很容易創(chuàng)建一個(gè)獨(dú)立運(yùn)行(運(yùn)行 Jar,內(nèi)嵌 Servlet 容器)準(zhǔn)生產(chǎn)級(jí)別的基于 Spring 框架的項(xiàng)目,使用 Spring Boot 你可以不用或者只需很少的 Spring 配置。
3、SpringBoot插件使用
spring-boot-devtools 實(shí)現(xiàn)熱部署,實(shí)際開發(fā)過(guò)程中,修改應(yīng)用的業(yè)務(wù)邏輯時(shí)常常需要重啟應(yīng)用,這顯得非常繁瑣,降低了開發(fā)效率,所以熱部署對(duì)于開發(fā)來(lái)說(shuō)顯得十分必要了 spring-boot-starter-aop 此插件沒(méi)什么好說(shuō)的了,aop是spring的兩大功能模塊之一,功能非常強(qiáng)大,為解耦提供了非常優(yōu)秀的解決方案。如:面向方面編程 spring-boot-starter-undertow 與spring boot 內(nèi)置undertow 插件 spring-boot-starter-test 測(cè)試工具 mybatis-plus-boot-starter 與spring boot整合MyBatisPlus的jar spring-boot-configuration-processor 整合SpringBoot配置提示
4、fastJson
阿里JSON解析器,詳細(xì)文檔請(qǐng)看官方 https://github.com/alibaba/fastjson
5、Hutool
Hutool是一個(gè)Java工具包,也只是一個(gè)工具包,它幫助我們簡(jiǎn)化每一行代碼,減少每一個(gè)方法,讓Java語(yǔ)言也可以“甜甜的”。Hutool最初是我項(xiàng)目中“util”包的一個(gè)整理,后來(lái)慢慢積累并加入更多非業(yè)務(wù)相關(guān)功能,并廣泛學(xué)習(xí)其它開源項(xiàng)目精髓,經(jīng)過(guò)自己整理修改,最終形成豐富的開源工具集。
6、Gradle
Gradle是一個(gè)基于Apache Ant和Apache Maven概念的項(xiàng)目自動(dòng)化構(gòu)建開源工具。它使用一種基于Groovy的特定領(lǐng)域語(yǔ)言(DSL)來(lái)聲明項(xiàng)目設(shè)置,目前也增加了基于Kotlin語(yǔ)言的kotlin-based DSL,拋棄了基于XML的各種繁瑣配置 官方 https://gradle.org/ 不會(huì)Gradle的先自己補(bǔ)習(xí)一下,比如:安裝Gradle,配置環(huán)境變量,一些jar引入如何配置,基本使用怎么使用
7、工程結(jié)構(gòu)
此工程是通過(guò)Kotlin+SpringBoot+MyBatisPlus搭建最簡(jiǎn)潔的前后端分離框架 框架升級(jí)Java語(yǔ)言SpringBoot+MyBatisPlus3.X+Gradle版本的框架,想學(xué)習(xí)Kotlin版本的請(qǐng)點(diǎn)擊藍(lán)色文章進(jìn)行下載源代碼。


8、Gradle配置
plugins?{
????id?'java'
????id?'idea'
}
/**
?*?使用Groovy語(yǔ)言語(yǔ)法定義版本號(hào)變量
?*/
def?spring_boot_version?=?"2.1.5.RELEASE"
def?mybatis_plus_version?=?"3.1.2"
def?mysql_version?=?"8.0.21"
def?druid_version?=?"1.1.23"
def?logback_version?=?"1.2.1"
def?fastjson_version?=?"1.2.73"
def?lombok_version?=?"1.18.12"
def?lang_version?=?"3.4"
def?io_version?=?"2.6"
def?guava_version?=?"18.0"
def?hutool_version?=?"5.3.10"
group?=?'com.flong'
version?=?'0.0.1-SNAPSHOT'
//jdk版本
sourceCompatibility?=?JavaVersion.VERSION_1_8
targetCompatibility?=?JavaVersion.VERSION_1_8
repositories?{
????//指定阿里云鏡像
????maven?{
????????url?'http://maven.aliyun.com/nexus/content/groups/public/'
????}
????mavenLocal()
????mavenCentral()
}
/**
?*?1、implementation?履行?、compile?編譯
?* 2、Gradle使用雙引號(hào)可?${變量}可以放入引號(hào)里面,單引號(hào)是不可以的。
?*?3、Gragle使用lombok需要引入annotationProcessor注解,否則不能使用lombok.
?*?4、mybatis-plus3.2.x以上版本引用了Kotlin的支持
?*?5、高版本Springboogt在spring-boot-dependencies-2.3.0.RELEASE.pom里面引入了mysql8.0.2的`8.0.20 `配置
?*/
dependencies?{
????implementation?"org.springframework.boot:spring-boot-starter:${spring_boot_version}"
????//排除tomcat使用undertow
????compile("org.springframework.boot:spring-boot-starter-web:${spring_boot_version}")?{
????????exclude?module:?"spring-boot-starter-tomcat"
????}
????compile?"org.springframework.boot:spring-boot-starter-undertow:${spring_boot_version}"
????//runtime?group:?'mysql',?name:?'mysql-connector-java',?version:?'5.1.42'
????compile?"org.springframework.boot:spring-boot-devtools:${spring_boot_version}"
????compile?"org.springframework.boot:spring-boot-configuration-processor:${spring_boot_version}"
????compile?"org.springframework.boot:spring-boot-starter-test:${spring_boot_version}"
????compile?"com.baomidou:mybatis-plus-extension:${mybatis_plus_version}"
????compile?"com.baomidou:mybatis-plus-boot-starter:${mybatis_plus_version}"
????compile?"mysql:mysql-connector-java:${mysql_version}"
????compile?"com.alibaba:druid:${druid_version}"
????compile?"ch.qos.logback:logback-classic:${logback_version}"
????compile?"com.alibaba:fastjson:${fastjson_version}"
????annotationProcessor?"org.projectlombok:lombok:${lombok_version}"
????compileOnly?"org.projectlombok:lombok:${lombok_version}"
????//testAnnotationProcessor?"org.projectlombok:lombok:${lombok_version}"
????//testCompileOnly?"org.projectlombok:lombok:${lombok_version}"
????compile?"org.apache.commons:commons-lang3:${lang_version}"
????compile?"commons-io:commons-io:${io_version}"
????compile?"com.google.guava:guava:${guava_version}"
????compile??"cn.hutool:hutool-all:${hutool_version}"
}
tasks.withType(JavaCompile)?{
????options.encoding?=?"UTF-8"
}
[compileJava,?javadoc,?compileTestJava]*.options*.encoding?=?"UTF-8"
9、數(shù)據(jù)庫(kù)SQL腳本
-- 創(chuàng)建表字段不建議用is開頭,在我Kotlin+Springboot+MyBatisPlus2.x整合也提到此問(wèn)題, -- 故此整合MyBatisPlus3.x版本,把表的is_deleted字段修改成del_flag,阿里開發(fā)手冊(cè)也提到此問(wèn)題.
DROP?TABLE?IF?EXISTS?`t_user`;
CREATE?TABLE?`t_user`?(
??`id`?int(11)?NOT?NULL?AUTO_INCREMENT?COMMENT?'自增id',
??`user_id`?bigint(20)?unsigned?NOT?NULL?DEFAULT?'0'?COMMENT?'用戶Id主鍵,IdWork生成',
??`user_name`?varchar(255)?DEFAULT?''?COMMENT?'用戶名',
??`pass_word`?varchar(255)?DEFAULT?''?COMMENT?'密碼',
??`del_flag`?int(2)?unsigned?NOT?NULL?DEFAULT?'0'?COMMENT?'是否刪除,0-不刪除,1-刪除',
??`create_time`?timestamp?NOT?NULL?DEFAULT?CURRENT_TIMESTAMP?COMMENT?'創(chuàng)建時(shí)間',
??PRIMARY?KEY?(`user_id`)?USING?BTREE,
??UNIQUE?KEY?`id`?(`id`)USING?BTREE
)ENGINE=INNODB?DEFAULT?CHARSET=utf8mb4?COMMENT='用戶表';
10、SpringBoot與MyBatisPlus3整合分頁(yè)代碼
@Configuration
public?class?MyBatisPlusConfig?{
????/**
?????*?分頁(yè)插件
?????*/
????@Bean
????public?PaginationInterceptor?paginationInterceptor()?{
????????return?new?PaginationInterceptor();
????}
}
11、SpringBoot與MyBatisPlus3分頁(yè)條件組裝器
/**
?*?將condition數(shù)據(jù)轉(zhuǎn)換成wrapper
?*/
public?class?BuildConditionWrapper?{
????public?static??QueryWrapper?build(List?conditions,?Class?clazz) ? {
????????//初始化mybatis條件構(gòu)造器
????????QueryWrapper?wrapper?=?Wrappers.query();
????????if?(conditions?==?null?||?conditions.size()?==?0)?{
????????????return?wrapper;
????????}
????????try?{
????????????for?(int?i?=?0;?i?????????????????Condition?condition?=?conditions.get(i);
????????????????if?(condition.getFieldName()?==?null)?{
????????????????????throw?new?BaseException("調(diào)用搜索接口時(shí),缺少關(guān)鍵字[fieldName]!");
????????????????}
????????????????//列名稱
????????????????String?columnName?=?getColumnName(condition.getFieldName(),?clazz);
????????????????if?(condition?==?null?||?condition.getOperation()?==?null)?{
????????????????????throw?new?BaseException("操作符不能為空!");
????????????????}
????????????????switch?(condition.getOperation())?{
????????????????????//等于
????????????????????case?EQ:
????????????????????????wrapper.eq(columnName,?condition.getValue());
????????????????????????break;
????????????????????//大于
????????????????????case?GT:
????????????????????????wrapper.gt(columnName,?condition.getValue());
????????????????????????break;
????????????????????//小于
????????????????????case?LT:
????????????????????????wrapper.lt(columnName,?condition.getValue());
????????????????????????break;
????????????????????//不等于
????????????????????case?NEQ:
????????????????????????wrapper.ne(columnName,?condition.getValue());
????????????????????????break;
????????????????????//大于等于
????????????????????case?GTANDEQ:
????????????????????????wrapper.ge(columnName,?condition.getValue());
????????????????????????break;
????????????????????//小于等于
????????????????????case?LTANDEQ:
????????????????????????wrapper.le(columnName,?condition.getValue());
????????????????????????break;
????????????????????case?LIKE:
????????????????????????wrapper.like(columnName,?condition.getValue());
????????????????????????break;
????????????????????case?ISNULL:
????????????????????????wrapper.isNull(columnName);
????????????????????????break;
????????????????????case?IN:
????????????????????????//value?:1,2,3,4,5,6
????????????????????????wrapper.inSql(columnName,?condition.getValue());
????????????????????????break;
????????????????????default:
????????????????????????break;
????????????????}
????????????????if?(condition.getJoinType()?==?JoinType.OR?&&?i?1)?{
????????????????????//下個(gè)條件為or連接且非最后一個(gè)條件,使用or進(jìn)行連接
????????????????????wrapper.or();
????????????????}
????????????}
????????????return?wrapper;
????????}?catch?(Exception?e)?{
????????????throw?new?BaseException("查詢條件不存在");
????????}
????}
????/**
?????*?@Descript?此條件構(gòu)建包裝器方法是支持多個(gè)表組裝成SQL字段的虛擬表,不支持實(shí)際存在的表
?????*?@Date?2019/6/21?13:32
?????*?@Author?liangjl
?????*/
????public?static??QueryWrapper?buildWarpper(List?conditions) ? {
????????//初始化mybatis條件構(gòu)造器
????????QueryWrapper?wrapper?=?Wrappers.query();
????????if?(conditions?==?null?||?conditions.size()?==?0)?{
????????????return?wrapper;
????????}
????????try?{
????????????for?(int?i?=?0;?i?????????????????Condition?condition?=?conditions.get(i);
????????????????if?(condition.getFieldName()?==?null)?{
????????????????????throw?new?BaseException("調(diào)用搜索接口時(shí),缺少關(guān)鍵字[fieldName]!");
????????????????}
????????????????//列名稱
????????????????String?columnName?=?condition.getFieldName();
????????????????if?(condition?==?null?||?condition.getOperation()?==?null)?{
????????????????????throw?new?BaseException("操作符不能為空!");
????????????????}
????????????????switch?(condition.getOperation())?{
????????????????????//等于
????????????????????case?EQ:
????????????????????????wrapper.eq(columnName,?condition.getValue());
????????????????????????break;
????????????????????//大于
????????????????????case?GT:
????????????????????????wrapper.gt(columnName,?condition.getValue());
????????????????????????break;
????????????????????//小于
????????????????????case?LT:
????????????????????????wrapper.lt(columnName,?condition.getValue());
????????????????????????break;
????????????????????//不等于
????????????????????case?NEQ:
????????????????????????wrapper.ne(columnName,?condition.getValue());
????????????????????????break;
????????????????????//大于等于
????????????????????case?GTANDEQ:
????????????????????????wrapper.ge(columnName,?condition.getValue());
????????????????????????break;
????????????????????//小于等于
????????????????????case?LTANDEQ:
????????????????????????wrapper.le(columnName,?condition.getValue());
????????????????????????break;
????????????????????case?LIKE:
????????????????????????wrapper.like(columnName,?condition.getValue());
????????????????????????break;
????????????????????case?IN:
????????????????????????//value?:1,2,3,4,5,6
????????????????????????wrapper.inSql(columnName,?condition.getValue());
????????????????????????break;
????????????????????default:
????????????????????????break;
????????????????}
????????????????if?(condition.getJoinType()?==?JoinType.OR?&&?i?1)?{
????????????????????//下個(gè)條件為or連接且非最后一個(gè)條件,使用or進(jìn)行連接
????????????????????wrapper.or();
????????????????}
????????????}
????????????return?wrapper;
????????}?catch?(Exception?e)?{
????????????throw?new?BaseException("查詢條件不存在");
????????}
????}
????/***
?????*?@Descript?獲取指定實(shí)體Bean的字段屬性
?????*?@Date?2019/6/19?14:51
?????*?@Author?liangjl
?????*/
????public?static?String?getColumnName(String?fieldName,?Class?clazz)?{
????????try?{
????????????//獲取泛型類型字段
????????????Field?field?=?clazz.getDeclaredField(fieldName);
????????????TableField?tableFieldAnno?=?field.getAnnotation(TableField.class);
????????????String?columnName?=?"";
????????????//獲取對(duì)應(yīng)數(shù)據(jù)庫(kù)字段
????????????if?(tableFieldAnno?!=?null?&&?StrUtil.isNotBlank(tableFieldAnno.value()))?{
????????????????//已定義數(shù)據(jù)庫(kù)字段,取定義值
????????????????columnName?=?tableFieldAnno.value();
????????????}?else?{
????????????????//未指定數(shù)據(jù)庫(kù)字段,默認(rèn)駝峰轉(zhuǎn)下劃線
????????????????columnName?=?NamingStrategyUtils.camelToUnderline(field.getName());
????????????}
????????????return?columnName;
????????}?catch?(NoSuchFieldException?e)?{
????????????throw?new?BaseException("查詢條件不存在");
????????}
????}
}
12、 實(shí)體
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper=false)
@TableName("t_user")
public?class?User?extends?Model<User>?implements?Serializable?{
????@TableId(type?=?IdType.ID_WORKER)
????private?Long?userId;
????/**
?????*?用戶名
?????*/
????private?String?userName;
????/**
?????*?密碼
?????*/
????private?String?passWord;
????/**
?????*?邏輯刪除(0-未刪除,1-已刪除)
?????*/
????@TableLogic
????private?String?delFlag;
????/**
?????*?創(chuàng)建時(shí)間,允許為空,讓數(shù)據(jù)庫(kù)自動(dòng)生成即可
?????*/
????private?Date?createTime;
}
13、 Mapper
BaseMapper是繼承了mybatisplus底層的代碼
public?interface?UserMapper?extends?BaseMapper<User>?{
}
14、 Service
ServiceImplr是繼承了mybatisplus底層的代碼
@Service
public?class?UserService?extends?ServiceImpl<UserMapper,?User>?{
}
15 、controller
控制層主要實(shí)現(xiàn)CURD,增加,修改,查詢,刪除、分頁(yè)無(wú)大常規(guī)操作接口操作 用戶分頁(yè),參數(shù)有多個(gè)使用下標(biāo)索引進(jìn)行處理.如果有兩個(gè)參數(shù)(如用戶名和地址):conditionList[0].fieldName=userName、 conditionList[0].fieldName=address 查詢是通過(guò)反射fieldName進(jìn)行去獲取表結(jié)構(gòu)userName、address 字段的。 未轉(zhuǎn)碼請(qǐng)求分頁(yè)地址: http://localhost:7011/user/page?conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=周 已轉(zhuǎn)碼請(qǐng)求分頁(yè)地址: http://localhost:7011/user/page?conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=%E5%91%A8
/**
?*?@Author:liangjl
?*?@Date:2020-08-16
?*?@Description:用戶控制層
?*/
@RestController
@RequestMapping("/user")
public?class?UserController?{
????@Autowired
????private?UserMapper?userMapper;
????@Autowired
????private?UserService?userService;
????/**
?????*?添加
?????*/
????@RequestMapping("/add")
????public?void?add()?{
????????userMapper.insert(User.builder().userName("周伯通").passWord("123456").build());
????}
????/**
?????*?修改
?????*?@param?user
?????*/
????@PutMapping("/updateById")
????public?void?updateById(@RequestBody?User?user)?{
????????userMapper.updateById(user);
????}
????/**
?????*?刪除通過(guò)多個(gè)主鍵Id進(jìn)行刪除
?????*?@param?ids
?????*/
????@DeleteMapping("/deleteByIds")
????public?void?deleteByIds(@RequestBody?List?ids) ?{
????????userMapper.deleteBatchIds(ids);
????}
????/**
?????*?通過(guò)指定Id進(jìn)行查詢
?????*
?????*?@param?userId
?????*/
????@GetMapping("/getOne/{userId}")
????public?void?getOne(@PathVariable("userId")?Long?userId)?{
????????User?user?=?userMapper.selectById(userId);
????????System.out.println(JSON.toJSON(user));
????}
????/**
?????*?用戶分頁(yè),參數(shù)有多個(gè)使用下標(biāo)索引進(jìn)行處理.如果有兩個(gè)參數(shù)(如用戶名和地址):conditionList[0].fieldName=userName、 conditionList[0].fieldName=address
?????*?未轉(zhuǎn)碼請(qǐng)求分頁(yè)地址:?http://localhost:7011/user/page?conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=周
?????*?已轉(zhuǎn)碼請(qǐng)求分頁(yè)地址:?http://localhost:7011/user/page?conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=%E5%91%A8
?????*?@param?page
?????*?@param?conditions?條件
?????*?@return
?????*/
????@GetMapping("/page")
????public?IPage?page(Page?page,?Conditions?conditions)? {
????????QueryWrapper?build?=?BuildConditionWrapper.build(conditions.getConditionList(),?User.class);
????????//通過(guò)lambda反射找到User實(shí)體類的createTime自動(dòng)進(jìn)行排序
????????build.lambda().orderByDesc(User::getCreateTime);
????????return?userService.page(page,?build);
????}
}
16、WebCofig工具類統(tǒng)一處理配置
消息轉(zhuǎn)換器,中文亂碼,Long的精度長(zhǎng)度問(wèn)題,時(shí)間格式等問(wèn)題 cors 跨域支持 可以用@CrossOrigin在controller上單獨(dú)設(shè)置 統(tǒng)一處理請(qǐng)求URL攔截器
@Configuration
@ConditionalOnClass(WebMvcConfigurer.class)
@Order(Ordered.HIGHEST_PRECEDENCE)
public?class?WebConfig?implements?WebMvcConfigurer?{
??@Bean
??public?HttpMessageConverters?customConverters()?{
????//創(chuàng)建fastJson消息轉(zhuǎn)換器
????FastJsonHttpMessageConverter?fastJsonConverter?=?new?FastJsonHttpMessageConverter();
????//創(chuàng)建配置類
????FastJsonConfig?fastJsonConfig?=?new?FastJsonConfig();
????//修改配置返回內(nèi)容的過(guò)濾
????fastJsonConfig.setSerializerFeatures(
????????//?格式化
????????SerializerFeature.PrettyFormat,
????????//?可解決long精度丟失?但會(huì)有帶來(lái)相應(yīng)的中文問(wèn)題
????????//SerializerFeature.BrowserCompatible,
????????//?消除對(duì)同一對(duì)象循環(huán)引用的問(wèn)題,默認(rèn)為false(如果不配置有可能會(huì)進(jìn)入死循環(huán))
????????SerializerFeature.DisableCircularReferenceDetect,
????????//?是否輸出值為null的字段,默認(rèn)為false
????????SerializerFeature.WriteMapNullValue,
????????//?字符類型字段如果為null,輸出為"",而非null
????????SerializerFeature.WriteNullStringAsEmpty,
????????//?List字段如果為null,輸出為[],而非null
????????SerializerFeature.WriteNullListAsEmpty
????);
????//?日期格式
????fastJsonConfig.setDateFormat("yyyy-MM-dd?HH:mm:ss");
????//?long精度問(wèn)題
????SerializeConfig?serializeConfig?=?SerializeConfig.globalInstance;
????serializeConfig.put(BigInteger.class,?ToStringSerializer.instance);
????serializeConfig.put(Long.class,?ToStringSerializer.instance);
????serializeConfig.put(Long.TYPE,?ToStringSerializer.instance);
????fastJsonConfig.setSerializeConfig(serializeConfig);
????//處理中文亂碼問(wèn)題
????List?fastMediaTypes?=?new?ArrayList<>();
????fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
????fastJsonConverter.setSupportedMediaTypes(fastMediaTypes);
????fastJsonConverter.setFastJsonConfig(fastJsonConfig);
????//將fastjson添加到視圖消息轉(zhuǎn)換器列表內(nèi)
????return?new?HttpMessageConverters(fastJsonConverter);
??}
??/**
???*?攔截器
???*/
??@Override
??public?void?addInterceptors(InterceptorRegistry?registry)?{
????//registry.addInterceptor(logInterceptor).addPathPatterns("/**");
????//registry.addInterceptor(apiInterceptor).addPathPatterns("/**");
??}
??/**
???*?cors?跨域支持?可以用@CrossOrigin在controller上單獨(dú)設(shè)置
???*/
??@Override
??public?void?addCorsMappings(CorsRegistry?registry)?{
????registry.addMapping("/**")
????????//設(shè)置允許跨域請(qǐng)求的域名
????????.allowedOrigins("*")
????????//設(shè)置允許的方法
????????.allowedMethods("*")
????????//設(shè)置允許的頭信息
????????.allowedHeaders("*")
????????//是否允許證書?不再默認(rèn)開啟
????????.allowCredentials(Boolean.TRUE);
??}
}
17、運(yùn)行結(jié)果
添加 http://localhost:7011/user/add 分頁(yè) http://localhost:7011/user/page?conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=%E5%91%A8 默認(rèn)當(dāng)前current 為1當(dāng)前第一頁(yè),size為10,當(dāng)前頁(yè)可以顯示10條數(shù)據(jù),也可以根據(jù)自己的情況進(jìn)行自定義 http://localhost:7011/user/page?current=1&size=20&conditionList[0].fieldName=userName&conditionList[0].operation=LIKE&conditionList[0].value=%E5%91%A8

國(guó)慶節(jié),倒計(jì)時(shí)最后2天,限量秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
1核2G,1年62元,3年200元,國(guó)慶秒殺
18、工程代碼與說(shuō)明
1 、以上問(wèn)題都是根據(jù)自己學(xué)習(xí)實(shí)際情況進(jìn)行總結(jié)整理,除了技術(shù)問(wèn)題查很多網(wǎng)上資料通過(guò)進(jìn)行學(xué)習(xí)之后梳理。 2、 在學(xué)習(xí)過(guò)程中也遇到很多困難和疑點(diǎn),如有問(wèn)題或誤點(diǎn),望各位老司機(jī)多多指出或者提出建議。本人會(huì)采納各種好建議和正確方式不斷完善現(xiàn)況,人在成長(zhǎng)過(guò)程中的需要優(yōu)質(zhì)的養(yǎng)料。 3、 導(dǎo)入代碼的時(shí)候遇到最多的問(wèn)題,我想應(yīng)該是Maven較多,此時(shí)不懂maven的童鞋們可以通過(guò)自身情況,進(jìn)行網(wǎng)上查資料學(xué)習(xí)。如通過(guò)網(wǎng)上找資料長(zhǎng)時(shí)間解決不了,或者框架有不明白可以通過(guò)博客留言,在能力范圍內(nèi)會(huì)盡力幫助大家解決問(wèn)題所在,希望在過(guò)程中一起進(jìn)步,一起成長(zhǎng)。 工程代碼在 base 分支 https://github.com/jilongliang/springboot/tree/base
推薦閱讀
程序員內(nèi)推群!北京!上海!廣州!深圳!杭州!鄭州!武漢!南京!西安
評(píng)論
圖片
表情
