上一页 1 ··· 8 9 10 11 12 13 下一页

2022年12月27日

SpringBoot - 自定义拦截器HandlerInterceptor

摘要: 1.实现HandlerInterceptor接口 /** * 自定义拦截器 */ public class MyInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequ 阅读全文

posted @ 2022-12-27 17:17 Mikasa-Ackerman 阅读(93) 评论(0) 推荐(0) 编辑

SpringBoot - 转换器Convert与SpringBoot支持的返回类型

摘要: 1.自定义转换器 @Configuration(proxyBeanMethods=false) public class AppConfig { @Bean public WebMvcConfigurer getWebMvcConfigurer() { return new WebMvcConfig 阅读全文

posted @ 2022-12-27 17:05 Mikasa-Ackerman 阅读(156) 评论(0) 推荐(0) 编辑

SpringBoot - 静态资源的默认存放位置与修改默认存放位置,默认配置文件加载的路径

摘要: 1.静态资源文件路径 静态资源文件路径是指用户可以直接通过游览器访问到文件的存放位置。按照优先级有一下4个路径: classpath:/META-INF/resources/ classpath:/resources/ classpath:/static/ classpath:/public/ 修改 阅读全文

posted @ 2022-12-27 16:20 Mikasa-Ackerman 阅读(1523) 评论(0) 推荐(0) 编辑

2022年12月20日

SpringBoot - Yaml语法

摘要: 测试用到的类: 类的属性必须重写Get与Set方法 不管属性是私有的还是公共的,必须重写Get与Set方法 @Component @ConfigurationProperties(prefix = "student") public class Student { //基本数据类型 byte dat 阅读全文

posted @ 2022-12-20 19:42 Mikasa-Ackerman 阅读(16) 评论(0) 推荐(0) 编辑

SpringBoot - @ImportResource,@ConfigurationProperties 让xml生效与类属性绑定配置文件

摘要: @ImportResource 作用:使用.xml配置文件 范围:必须使用在主程序@SpringBootApplication或配置类上@Configuration @SpringBootApplication @ImportResource("classpath:application.xml") 阅读全文

posted @ 2022-12-20 18:08 Mikasa-Ackerman 阅读(98) 评论(0) 推荐(0) 编辑

SpringBoot - 条件注解 @Conditional

摘要: @ConditiOnBean 作用:如果Spring容器里面存在指定的Bean则生效 范围:类上,方法上,一般在配置类中使用 参数:value 参数类型Class[],name 参数类型String[] IOC容器中组件的名称 @ConditiOnMissingBean 作用:如果Spring容器里 阅读全文

posted @ 2022-12-20 17:42 Mikasa-Ackerman 阅读(67) 评论(0) 推荐(0) 编辑

SpringBoot - @Import注解

摘要: @Import 作用:用来导入配置类或者一些需要前置加载的类,注入到IOC容器当中 范围:类上,一般使用在被@Configuration修饰的类上 参数:value 数据类型为class[] 注入普通类 @Configuration @Import({Object.class,Student.cla 阅读全文

posted @ 2022-12-20 16:58 Mikasa-Ackerman 阅读(53) 评论(0) 推荐(0) 编辑

SpringBoot - 配置包扫描注解@ComponentScan

摘要: @ComponentScan 作用:配置包扫描规则 范围:主程序类上(被@SpringBootApplication修饰),或配置类上(被@Configuration修饰) 参数:value 指定要扫描的包,excludeFilters 配置排除规则,includeFilters 配包含规则 注意: 阅读全文

posted @ 2022-12-20 16:02 Mikasa-Ackerman 阅读(2813) 评论(0) 推荐(0) 编辑

SpringBoot - MVC三层架构注解注入到容器中与从IOC容器获取实例注解

摘要: MVC三层架构注解 @RestController 控制层 @Controller 控制层 @Service 业务层 @Repository 持久层 @Component 作用:把类注入到IOC容器当中 范围:类上 参数:value 给类起类名 从IOC容器中获取实例注解 @Autowired 作用 阅读全文

posted @ 2022-12-20 15:34 Mikasa-Ackerman 阅读(79) 评论(0) 推荐(0) 编辑

SpringBoot - @Configuration,@Bean,@Scope 组件注入容器

摘要: @Configuration 作用:声明一个类为配置类,替代之前使用的xml文件 范围:类上 参数:proxyBeanMethods:boolean(default=true) 基本使用:注册一个类到IOC容器中 @Configuration public class MyConfiguration 阅读全文

posted @ 2022-12-20 15:06 Mikasa-Ackerman 阅读(111) 评论(0) 推荐(0) 编辑

上一页 1 ··· 8 9 10 11 12 13 下一页

导航