aj-report报表
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.3 KiB

2 months ago
  1. ## 后端springboot
  2. ### 采用redis缓存
  3. #### 1.pom.xml文件改动
  4. - 1、增加redis依赖,删除exclusions即可
  5. ```xml
  6. <dependency>
  7. <groupId>com.anji-plus</groupId>
  8. <artifactId>spring-boot-gaea</artifactId>
  9. <version>2.0.5.RELEASE</version>
  10. <!--删除下方内容-->
  11. <exclusions>
  12. <exclusion>
  13. <groupId>org.springframework.boot</groupId>
  14. <artifactId>spring-boot-starter-data-redis</artifactId>
  15. </exclusion>
  16. </exclusions>
  17. <!--删除-->
  18. </dependency>
  19. ```
  20. - 2、 删除ehcache相关依赖
  21. ```xml
  22. <dependency>
  23. <groupId>net.sf.ehcache</groupId>
  24. <artifactId>ehcache</artifactId>
  25. <version>2.10.6</version>
  26. </dependency>
  27. ```
  28. #### 2.删除代码
  29. - 1、删除cache文件夹
  30. 目录地址:com.anjiplus.template.gaea.business.cache
  31. - 2、删除相关bean
  32. 文件地址:com.anjiplus.template.gaea.business.config.BusinessAutoConfiguration.java
  33. ```java
  34. @Bean
  35. public CacheHelper gaeaCacheHelper(){
  36. return new ReportCacheHelper();
  37. }
  38. @Bean
  39. public EhCacheCache ehCacheCache() {
  40. return (EhCacheCache) ehCacheCacheManager().getCache("reportCache");
  41. }
  42. /**
  43. * 创建ehCacheCacheManager
  44. */
  45. @Bean
  46. public EhCacheCacheManager ehCacheCacheManager() {
  47. return new EhCacheCacheManager();
  48. }
  49. ```
  50. 底层的实现方式如下:
  51. CacheHelper底层默认实现为RedisCacheHelper。
  52. @ConditionalOnMissingBean 注解起到的作用
  53. ```java
  54. package com.anji.plus.gaea;
  55. @Configuration
  56. @EnableConfigurationProperties({GaeaProperties.class})
  57. public class GaeaAutoConfiguration {
  58. @Bean
  59. @ConditionalOnClass({RedisAutoConfiguration.class})
  60. @ConditionalOnMissingBean
  61. public CacheHelper cacheHelper() {
  62. return new RedisCacheHelper();
  63. }
  64. }
  65. ```
  66. #### 3.bootstrap.yml加上对应的redis配置
  67. 注意yml格式
  68. ```yaml
  69. spring:
  70. redis:
  71. host: 10.108.x.x
  72. port: 6379
  73. password: ****
  74. database: 1
  75. timeout: 10000
  76. pool:
  77. max-active: 8
  78. max-idle: 8
  79. max-wait: -1
  80. min-idle: 0
  81. ```
  82. 哨兵模式
  83. ```yaml
  84. spring:
  85. redis:
  86. sentinel:
  87. master: master01
  88. nodes: 10.108.xx.xx:26379,10.108.xx.xx:26379,10.108.xx.xx:26379
  89. database: 1
  90. password: *******
  91. timeout: 10000
  92. ```