Guns使用

首先是系统的配置文件

SpringMvcConfiguration是对spring mvc框架的配置

配置了spring mvc拦截器,用于拦截请求并进行有关处理

@Override

public void addInterceptors(InterceptorRegistry registry){

        registry.addInterceptor(authJwtTokenSecurityInterceptor);

        registry.addInterceptor(permissionSecurityInterceptor);

}


静态资源映射表示开放assets目录下的所有静态资源,访问/assets/**路径时,程序返回/assets/目录下的资源文件

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/assets/");
}

重写系统的默认错误提示,让错误界面更加美观

@Bean
public CustomErrorAttributes gunsErrorAttributes() {
    return new CustomErrorAttributes();
}

 

MapperScanConfiguration是对mybatis mapper文件的扫描的配置

@Configuration
@MapperScan(basePackages = {"cn.stylefeng.**.mapper"})
public class MapperScanConfiguration {

}

第二个就是在resource目录中的配置文件:

db.migration.mysql目录存放了flyway脚本

使用flyway可以不用手动初始化sql脚本,每次Guns启动会自动检测这个目录下的脚本有没有被初始化过,第一次运行项目会执行所有的sql脚本。

application.yml配置文件

这个配置文件中存放了项目的基础配置,包括springtomcatspring mvcmybatis-plus等配置。

原文地址:https://www.cnblogs.com/zhukaile/p/15690378.html