随笔分类 -  Spring Boot

Spring boot 梳理 - @SpringBootConfiguration
摘要:@SpringBootConfiguration继承自@Configuration,二者功能也一致,标注当前类是配置类, 并会将当前类内声明的一个或多个以@Bean注解标记的方法的实例纳入到spring容器中,并且实例名就是方法名。 阅读全文

posted @ 2019-01-09 22:15 手握太阳 阅读(2204) 评论(0) 推荐(0)

Spring boot 梳理 - 全局配置文件application.properties或者是application.yml,在resources目录下或者类路径下的/config下,一般我们放到resources下。
摘要:全局配置文件application.properties或者是application.yml,在resources目录下或者类路径下的/config下,一般我们放到resources下。 阅读全文

posted @ 2019-01-09 22:00 手握太阳 阅读(2713) 评论(0) 推荐(0)

Spring boot 梳理 - WebMvcConfigurer接口 使用案例
摘要:转:https://yq.aliyun.com/articles/617307 SpringBoot 确实为我们做了很多事情, 但有时候我们想要自己定义一些Handler,Interceptor,ViewResolver,MessageConverter,该怎么做呢。在Spring Boot 1.5 阅读全文

posted @ 2019-01-08 22:05 手握太阳 阅读(1195) 评论(0) 推荐(0)

Spring boot 梳理 - @Conditional
摘要:@Conditional(TestCondition.class) 这句代码可以标注在类上面,表示该类下面的所有@Bean都会启用配置,也可以标注在方法上面,只是对该方法启用配置。 spring框架还提供了很多@Condition给我们用,当然总结用语哪种好理解,看给位读者喽 @Conditiona 阅读全文

posted @ 2019-01-08 21:51 手握太阳 阅读(407) 评论(0) 推荐(0)

Spring boot 梳理 -@SpringBootApplication、@EnableAutoConfiguration与(@EnableWebMVC、WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter)
摘要:@EnableWebMvc=继承DelegatingWebMvcConfiguration=继承WebMvcConfigurationSupport 直接看源码,@EnableWebMvc实际上引入一个DelegatingWebMvcConfiguration @Retention(Retentio 阅读全文

posted @ 2019-01-08 21:28 手握太阳 阅读(1447) 评论(0) 推荐(0)

Spring boot 梳理 - mappingJackson2JsonView
摘要:MappingJacksonJsonView已被废弃了: http://static.javadoc.io/org.springframework/spring-webmvc/4.0.1.RELEASE/deprecated-list.html 而升级为MappingJackson2JsonView 阅读全文

posted @ 2019-01-03 21:39 手握太阳 阅读(2818) 评论(0) 推荐(0)

Spring boot 梳理 - 显示Springboot默认自动生成的bean
摘要:@Autowired public ApplicationContext context; @Bean public ViewResolver freeMarkerViewResolver(){ String[] arr=context.getBeanDefinitionNames(); for(int i=0;i<arr.lengt... 阅读全文

posted @ 2019-01-03 20:56 手握太阳 阅读(1000) 评论(0) 推荐(0)

Spring boot 梳理 - 模版引擎 -freemarker
摘要:开发环境中关闭缓存 spring: thymeleaf: cache: false freemarker: cache: false Spring boot 集成 freemarker org.springframework.boot spring-boot-starter... 阅读全文

posted @ 2019-01-01 22:03 手握太阳 阅读(168) 评论(0) 推荐(0)

Spring boot 梳理 - Spring boot 与 JSP
摘要:若使用Spring boot 开发web应用中使用jsp,需要打包成war,并部署到非嵌入式servlet容器中运行,在嵌入式servlet中无法运行,且需要匹配非嵌入式servlet版本与Spring boot开发中的版本一致性 阅读全文

posted @ 2019-01-01 22:01 手握太阳 阅读(299) 评论(0) 推荐(0)

Spring boot 官网学习笔记 - logging
摘要:为什么要用SLF4J+Logback 替换commons-logging+log4j? 基于slf4j的日志使用 切换日志框架(无意义,slf4j+logback已经是最佳实现) All the supported logging systems can have the logger levels 阅读全文

posted @ 2019-01-01 10:39 手握太阳 阅读(2760) 评论(0) 推荐(0)

Spring boot 梳理 - 在bean中使用命令行参数-自动装配ApplicationArguments
摘要:If you need to access the application arguments that were passed to SpringApplication.run(…​), you can inject a org.springframework.boot.ApplicationAr 阅读全文

posted @ 2018-12-31 10:34 手握太阳 阅读(762) 评论(0) 推荐(0)

Spring boot 梳理 - SpringApplication
摘要:Web Environment A SpringApplication attempts to create the right type of ApplicationContext on your behalf. The algorithm used to determine a WebAppli 阅读全文

posted @ 2018-12-31 10:13 手握太阳 阅读(171) 评论(0) 推荐(0)

Spring boot 官网学习笔记 - Spring Boot 属性配置和使用(转)-application.properties
摘要:Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active). @TestPropertySource annotatio 阅读全文

posted @ 2018-12-28 22:31 手握太阳 阅读(527) 评论(0) 推荐(0)

Spring boot 官网学习笔记 - Spring DevTools 介绍
摘要:想要使用devtools支持,只需使用dependencies将模块依赖关系添加到你的构建中 Spring Boot 支持的一些库中会使用缓存来提高性能。例如模版引擎将缓存编译后的模板,以避免重复解析模板文件。 此外,Spring MVC可以在服务静态资源时向响应中添加HTTP缓存头。 虽然缓存在生 阅读全文

posted @ 2018-12-28 21:55 手握太阳 阅读(690) 评论(0) 推荐(0)

Spring boot 梳理 - Spring boot自动注册DispatcherServlet
摘要:首先,DispatcherServlet被作为一个普通Bean被定义和注册到容器; 然后,又定义了另外一个ServletRegistrationBean bean用来添加该DispatcherServlet bean到ServletContext; 1.@WebServlet注解: 这个是javae 阅读全文

posted @ 2018-12-27 22:53 手握太阳 阅读(4886) 评论(0) 推荐(0)

Spring boot - 梳理 - 根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置
摘要:根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置 阅读全文

posted @ 2018-12-27 22:25 手握太阳 阅读(272) 评论(0) 推荐(0)

Spring boot 梳理 - SpringBoot中注入ApplicationContext对象的三种方式
摘要:直接注入(Autowired) @Configuration public class OAConfig { @Autowired private ApplicationContext applicationContext; @Bean public PersonUtils personUtil(){ boolean bool=app... 阅读全文

posted @ 2018-12-27 22:06 手握太阳 阅读(8726) 评论(0) 推荐(0)

Spring boot 官网学习笔记 - Auto-configuration(@SpringBootApplication、@EnableAutoConfiguration、@Configuration)
摘要:Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For exam 阅读全文

posted @ 2018-12-26 20:28 手握太阳 阅读(484) 评论(0) 推荐(0)

Spring boot 官网学习笔记 - Configuration Class(@import)
摘要:推荐使用 Java-based configuration ,也可以使用xml we generally recommend that your primary source be a single @Configuration class. Usually the class that defines the main method is a good candidate as the pr... 阅读全文

posted @ 2018-12-24 21:27 手握太阳 阅读(294) 评论(0) 推荐(0)

Spring boot 梳理 - 代码结构(Main类的位置)
摘要:Spring boot 对代码结构无特殊要求,但有个套最佳实践的推荐 不要使用没有包名的类。没有包名时,@ComponentScan, @EntityScan, or @SpringBootApplication 可能会有问题。 Main类在包路径中的位置:强烈建议main类放在包的根路径上。We generally recommend that you locate your main app... 阅读全文

posted @ 2018-12-21 22:34 手握太阳 阅读(1724) 评论(0) 推荐(0)

导航