本文共 1596 字,大约阅读时间需要 5 分钟。
一。Spring Boot 核心
(1)基本配置
【
1.@SpringBootApplication(组合@Configuration,@EnableAutoConfiguration,@ComponentScan
2. 配置文件{
1.在resources or config 目录下添加xxx.properties
2.starter pom
3.第三方starter pom
4..XML配置
}
3.外部配置{
1.命令行参 (Java -jar xx.jar --server.port=9090)
}
4.日志配置{
1.配置日志级别
2.配置日志文件
}
5.Profile配置{
eg:spring.profiles.active=profile, 在新建appliacation-{profile}.properties
}
】
二。Spring Boot的web开发
【
(1)Thymeleaf模板引擎
【
1.引入Thymeleaf
2.访问model中的数据(${ })
3.model中的数据迭代(th:each=“xx:${ }”)
4.数据判断(th:if="${ } ")
5.在JavaScript中访问model(通过th:line=“JavaScript”添加标签,通过[[${ }]]获取值)
】
(2)与Spring MVC集成(通过ThymeleafViewResolver()or ThymeleafView)
(3)Spring Boot的Thymeleaf支持(通过thymeleaf包)
(4)Web相关配置
【
1.Spring Boot提供的自动配置(ViewResolver,自动配置的静态资源,Formatter和Converter,HttpMessageConverters,静态首页支持)
2.SSL(server.ssl.key-store=.keystore)
3.Favicon(Spring.mvc.favicon.enabled=false)
】
(5)WebSocket
【
1.广播式
【1.配置webscokt
2.浏览器向服务端发送消息类
3.服务端向浏览器发送消息类
4.控制器
5.添加脚本
6.演示页面
7.配置viewController
】
2.点对点式 (配置WebSocket,增加一个消息代理)
】
三。Spring Boot 数据访问
【
(1)Spring Data JPA{
1.继承JpaRepository
2.配置@EnableJpaRepositories开启支持
3.接口定义方法(eg:
List<Person> findByName(String name)(属性名查询)
or @NamedQuery or @Query or Specification)
}
(2)自定义Repository{
1.定义Repository接口
2.定义接口实现
3.自定义RepositoryFactoryBean
}
(3)Spring Data REST(repository转化成REST服务){
1.继承方式 RepositoryRestMvcConfiguration
2.导入方式 @Import(RepositoryRestMvcConfiguration.calss)
}
(4)声明式事务{
1.Spring的事务机制(JDBC,JPA,Hibernate,JDO,分布式事务)
2.声明式事务(propagationtion,isolation,timeout,readOnly,rollbackFor,noRollbackFor)
}
(5)数据缓存{
1.CacheManager
2.Cache
3.EhCache
4.Guava
5.Redis
}
】
转载地址:https://blog.csdn.net/qq_39736176/article/details/81389960 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!