余瑜的博客 余瑜的博客
首页
  • 并发
  • 线程池
  • spring
  • maven
  • 其他
  • redis
  • mysql
  • linux
  • zookeeper
  • docker
  • terminal
  • kong插件开发
  • 资料
  • leetCode-简单
  • blog
  • 其他
关于
GitHub (opens new window)
首页
  • 并发
  • 线程池
  • spring
  • maven
  • 其他
  • redis
  • mysql
  • linux
  • zookeeper
  • docker
  • terminal
  • kong插件开发
  • 资料
  • leetCode-简单
  • blog
  • 其他
关于
GitHub (opens new window)
  • 并发

  • 线程池

  • spring

    • Spring 统一资源加载策略
    • BeanDefinition加载、解析、处理、注册
    • BeanFactory1-DefaultSingletonBeanRegistry
    • spring-boot-data-elasticsearch
    • springboot配置Druid监控
    • springboot项目初始化时读取数据库
      • 实现InitializingBean, ServletContextAware
    • 文件上传
    • SpringBoot优雅停机的正确姿势.md
    • spring源码阅读神器
  • maven

  • 其他

  • JAVA
  • spring
余瑜
2019-05-16
目录

springboot项目初始化时读取数据库

# 实现InitializingBean, ServletContextAware

@Service
public class ConstanstMap  implements InitializingBean, ServletContextAware {

    public final static Map<String, String> initConfig = new HashMap<>();


    @Resource
    private ContentVoMapper contentDao;

    @Override
    public void afterPropertiesSet() throws Exception {

    }

    @Override
    public void setServletContext(ServletContext servletContext) {
        ContentVoExample contentVoExample = new ContentVoExample();
        contentVoExample.createCriteria().andTypeEqualTo(Types.PAGE.getType());
        List<ContentVo> contentVos = contentDao.selectByExampleWithBLOBs(contentVoExample);
        for (ContentVo contentVo : contentVos) {
            initConfig.put(contentVo.getSlug(),contentVo.getTitle());

        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
上次更新: 2021/02/20, 19:26:07

← springboot配置Druid监控 文件上传→

Theme by Vdoing | Copyright © 2018-2022 逆光世间 | 备案号: 京ICP备19016086号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式