首页>代码>基于SpringBoot+Vue实现的社团管理系统>/club-management/server/src/main/java/com/bishe/club/Application.java
package com.bishe.club; import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.util.ArrayList; import java.util.List; @SpringBootApplication @MapperScan({"com.bishe.club.dao"}) @EnableCaching public class Application implements WebMvcConfigurer{ /** * JSON格式转换器 * @return */ @Bean public HttpMessageConverters fastJsonHttpMessageConverters() { FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); List<MediaType> fastMedisTypes = new ArrayList<>(); fastMedisTypes.add(MediaType.APPLICATION_JSON); fastConverter.setSupportedMediaTypes(fastMedisTypes); fastConverter.setFastJsonConfig(fastJsonConfig); HttpMessageConverter<?> converter = fastConverter; return new HttpMessageConverters(converter); } /** * 添加MySQL分页查询 * @return */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOriginPatterns("*") .allowCredentials(true) .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH") .maxAge(3600); } }; } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
最近下载更多
jc121140 LV3
4月15日
玖零定制问题修复 LV34
4月4日
dapeng0011 LV13
4月4日
yuan666 LV1
3月27日
xiaozhi丶 LV14
3月24日
crazyAndy LV7
3月20日
wanglinddad LV55
3月9日
zhujunnan LV12
3月8日
wbw123 LV5
3月4日
可是不知道么 LV23
3月1日
最近浏览更多
kenhomeliu LV29
4月30日
1941549176
4月29日
暂无贡献等级
denliv_hui LV13
4月26日
ilovecode521 LV3
4月20日
khhuyvhgcd LV1
4月15日
玖零定制问题修复 LV34
4月4日
dapeng0011 LV13
4月4日
邓艺妮
4月3日
暂无贡献等级
微信网友_6927932988952576 LV12
3月30日
儒雅男士 LV8
3月27日