SpringBoot同时集成Redis和Guava作为缓存组件

Stella981
• 阅读 657

请先看

https://my.oschina.net/u/3866531/blog/1840386

CompositeCacheManager****

Composite,混合的,混成的

Spring提供CompositeCacheManager的主要目的就是为了混合使用多种缓存时进行管理。

一、实际测试--CompositeCacheManager中打断点****

断点打在getCache上****

SpringBoot同时集成Redis和Guava作为缓存组件

GuavaDataCache源码--去掉类上的******@CacheConfig(cacheManager = "guavaCacheManager")**注解

package com.ding.data.cache;


import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.Map;


import javax.annotation.PostConstruct;


import org.springframework.cache.annotation.CacheEvict;

import org.springframework.cache.annotation.CachePut;

import org.springframework.cache.annotation.Cacheable;

import org.springframework.stereotype.Service;


@Service

//@CacheConfig(cacheManager = "guavaCacheManager")

public class GuavaDataCache {


private Map<Long, String> dataMap = new HashMap<Long, String>();


/**

 * 初始化

 */

@PostConstruct

public void init() {

dataMap.put(1L, "张三");

dataMap.put(2L, "李四");

dataMap.put(3L, "王五");

}


/**

 * 查询

 * 如果数据没有缓存,那么从dataMap里面获取,如果缓存了,

 * 那么从guavaDemo里面获取

 * 并且将缓存的数据存入到 guavaDemo里面

 * 其中key 为 #id+dataMap

 */

@Cacheable(value="guavaDemo" ,key="#id + 'dataMap'")

public String query(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : query id is " + id);

return dataMap.get(id);

}


/**

 * 插入 或者更新

 * 插入或更新数据到dataMap中

 * 并且缓存到 guavaDemo中

 * 如果存在了那么更新缓存中的值

 * 其中key 为 #id+dataMap

 */

@CachePut(value="guavaDemo" ,key="#id + 'dataMap'")

public String put(Long id, String value) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : add data ,id is "+ id);

dataMap.put(id, value);

// data persistence

return value;

}


/**

 * 删除

 * 删除dataMap里面的数据

 * 并且删除缓存guavaDemo中的数据

 * 其中key 为 #id+dataMap

 */

@CacheEvict(value="guavaDemo" , key="#id + 'dataMap'")

public void remove(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : remove id is "+ id + " data");

dataMap.remove(id);

// data remove  

}


}

RedisDataCache源码--去掉类上的******@CacheConfig(cacheManager = "redisCacheManager")**注解

package com.ding.data.cache;


import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.Map;


import javax.annotation.PostConstruct;


import org.springframework.cache.annotation.CacheEvict;

import org.springframework.cache.annotation.CachePut;

import org.springframework.cache.annotation.Cacheable;

import org.springframework.stereotype.Service;


@Service

//@CacheConfig(cacheManager = "redisCacheManager")

public class RedisDataCache {


private Map<Long, String> dataMap = new HashMap<Long, String>();


/**

 * 初始化

 */

@PostConstruct

public void init() {

dataMap.put(1L, "111");

dataMap.put(2L, "222");

dataMap.put(3L, "333");

}


/**

 * 查询

 * 如果数据没有缓存,那么从dataMap里面获取,如果缓存了,

 * 那么从guavaDemo里面获取

 * 并且将缓存的数据存入到 guavaDemo里面

 * 其中key 为 #id+dataMap

 */

@Cacheable(value="redisDemo" ,key="#id + 'dataMap'")

public String query(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : query id is " + id);

return dataMap.get(id);

}


/**

 * 插入 或者更新

 * 插入或更新数据到dataMap中

 * 并且缓存到 guavaDemo中

 * 如果存在了那么更新缓存中的值

 * 其中key 为 #id+dataMap

 */

@CachePut(value="redisDemo" ,key="#id + 'dataMap'")

public String put(Long id, String value) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : add data ,id is "+ id);

dataMap.put(id, value);

// data persistence

return value;

}


/**

 * 删除

 * 删除dataMap里面的数据

 * 并且删除缓存guavaDemo中的数据

 * 其中key 为 #id+dataMap

 */

@CacheEvict(value="redisDemo" , key="#id + 'dataMap'")

public void remove(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : remove id is "+ id + " data");

dataMap.remove(id);

// data remove  

}

}

访问http://localhost:8080/get?id=1,进入断点,看到如下

SpringBoot同时集成Redis和Guava作为缓存组件

访问http://localhost:8080/getr?id=1,进入断点,看到如下

SpringBoot同时集成Redis和Guava作为缓存组件

所以可见此时是通过CompositeCacheManager进行管理的,CacheConfig类中的CompositeCacheManager** 起作用了**

package com.ding.data.config;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.concurrent.TimeUnit;


import javax.annotation.Resource;


import org.springframework.boot.ApplicationArguments;

import org.springframework.boot.ApplicationRunner;

import org.springframework.cache.CacheManager;

import org.springframework.cache.guava.GuavaCacheManager;

import org.springframework.cache.support.CompositeCacheManager;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.Primary;

import org.springframework.data.redis.cache.RedisCacheManager;

import org.springframework.data.redis.core.RedisTemplate;

import org.springframework.data.redis.serializer.StringRedisSerializer;


import com.google.common.cache.CacheBuilder;

import com.google.common.collect.Lists;


@Configuration

public class CacheConfig implements ApplicationRunner {

@Resource

private List<CacheManager> cacheManagers;


public void run(ApplicationArguments args) throws Exception {

System.out.println("CacheManager大小为=========" + cacheManagers.size());

System.out.println("=================================================");

for(CacheManager c:cacheManagers){

System.out.println(c.getCacheNames());

}

}


@Bean(name = "redisCacheManager")

public RedisCacheManager redisCacheManager(

RedisTemplate<Object, Object> redisTemplate) {

redisTemplate.setKeySerializer(new StringRedisSerializer());

RedisCacheManager redisCacheManager = new RedisCacheManager(

redisTemplate);

redisCacheManager.setCacheNames(Arrays.asList("redisDemo"));

redisCacheManager.setUsePrefix(true);

return redisCacheManager;

}


@Bean(name = "guavaCacheManager")

public GuavaCacheManager getGuavaCacheManager() {

GuavaCacheManager guavaCacheManager = new GuavaCacheManager();

guavaCacheManager.setCacheBuilder(CacheBuilder.newBuilder()

.expireAfterWrite(3600, TimeUnit.SECONDS).maximumSize(1000));

ArrayList<String> guavaCacheNames = Lists.newArrayList();

guavaCacheNames.add("guavaDemo");

guavaCacheManager.setCacheNames(guavaCacheNames);

return guavaCacheManager;

}


@Bean(name = "cacheManager")

@Primary

public CompositeCacheManager cacheManager(

RedisCacheManager redisCacheManager,

GuavaCacheManager guavaCacheManager) {

CompositeCacheManager cacheManager = new CompositeCacheManager(

redisCacheManager, guavaCacheManager);

return cacheManager;

}

}
  • 二、实际测试--CompositeCacheManager中打断点****

断点打在getCache上****

SpringBoot同时集成Redis和Guava作为缓存组件

GuavaDataCache源码--加上类上的******@CacheConfig(cacheManager = "guavaCacheManager")**注解

package com.ding.data.cache;


import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.Map;


import javax.annotation.PostConstruct;


import org.springframework.cache.annotation.CacheEvict;

import org.springframework.cache.annotation.CachePut;

import org.springframework.cache.annotation.Cacheable;

import org.springframework.stereotype.Service;


@Service

@CacheConfig(cacheManager = "guavaCacheManager")

public class GuavaDataCache {


private Map<Long, String> dataMap = new HashMap<Long, String>();


/**

 * 初始化

 */

@PostConstruct

public void init() {

dataMap.put(1L, "张三");

dataMap.put(2L, "李四");

dataMap.put(3L, "王五");

}


/**

 * 查询

 * 如果数据没有缓存,那么从dataMap里面获取,如果缓存了,

 * 那么从guavaDemo里面获取

 * 并且将缓存的数据存入到 guavaDemo里面

 * 其中key 为 #id+dataMap

 */

@Cacheable(value="guavaDemo" ,key="#id + 'dataMap'")

public String query(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : query id is " + id);

return dataMap.get(id);

}


/**

 * 插入 或者更新

 * 插入或更新数据到dataMap中

 * 并且缓存到 guavaDemo中

 * 如果存在了那么更新缓存中的值

 * 其中key 为 #id+dataMap

 */

@CachePut(value="guavaDemo" ,key="#id + 'dataMap'")

public String put(Long id, String value) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : add data ,id is "+ id);

dataMap.put(id, value);

// data persistence

return value;

}


/**

 * 删除

 * 删除dataMap里面的数据

 * 并且删除缓存guavaDemo中的数据

 * 其中key 为 #id+dataMap

 */

@CacheEvict(value="guavaDemo" , key="#id + 'dataMap'")

public void remove(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : remove id is "+ id + " data");

dataMap.remove(id);

// data remove  

}


}

RedisDataCache源码--去掉类上的******@CacheConfig(cacheManager = "redisCacheManager")**注解

package com.ding.data.cache;


import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.Map;


import javax.annotation.PostConstruct;


import org.springframework.cache.annotation.CacheEvict;

import org.springframework.cache.annotation.CachePut;

import org.springframework.cache.annotation.Cacheable;

import org.springframework.stereotype.Service;


@Service

@CacheConfig(cacheManager = "redisCacheManager")

public class RedisDataCache {


private Map<Long, String> dataMap = new HashMap<Long, String>();


/**

 * 初始化

 */

@PostConstruct

public void init() {

dataMap.put(1L, "111");

dataMap.put(2L, "222");

dataMap.put(3L, "333");

}


/**

 * 查询

 * 如果数据没有缓存,那么从dataMap里面获取,如果缓存了,

 * 那么从guavaDemo里面获取

 * 并且将缓存的数据存入到 guavaDemo里面

 * 其中key 为 #id+dataMap

 */

@Cacheable(value="redisDemo" ,key="#id + 'dataMap'")

public String query(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : query id is " + id);

return dataMap.get(id);

}


/**

 * 插入 或者更新

 * 插入或更新数据到dataMap中

 * 并且缓存到 guavaDemo中

 * 如果存在了那么更新缓存中的值

 * 其中key 为 #id+dataMap

 */

@CachePut(value="redisDemo" ,key="#id + 'dataMap'")

public String put(Long id, String value) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : add data ,id is "+ id);

dataMap.put(id, value);

// data persistence

return value;

}


/**

 * 删除

 * 删除dataMap里面的数据

 * 并且删除缓存guavaDemo中的数据

 * 其中key 为 #id+dataMap

 */

@CacheEvict(value="redisDemo" , key="#id + 'dataMap'")

public void remove(Long id) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println(sdf.format(new Date()) + " : remove id is "+ id + " data");

dataMap.remove(id);

// data remove  

}

}

访问http://localhost:8080/get?id=1,没进入断点

访问http://localhost:8080/getr?id=1,没进入断点

所以可见,此时因为标注上了 @CacheConfig(cacheManager =** "guavaCacheManager"******)** @CacheConfig(cacheManager = "redisCacheManager"******)** ,所以直接就知道需要用哪个CacheManager了,不需要CompositeCacheManager去匹配了**

直接去掉CacheConfig类中的CompositeCacheManager** ,在不同的缓存上加上 @CacheConfig(cacheManager = "guavaCacheManager"******)** @CacheConfig(cacheManager = ****"redisCacheManager"********)**,是否可以?——测试一下

此时的CacheConfig类代码

package com.ding.data.config;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.concurrent.TimeUnit;


import javax.annotation.Resource;


import org.springframework.boot.ApplicationArguments;

import org.springframework.boot.ApplicationRunner;

import org.springframework.cache.CacheManager;

import org.springframework.cache.guava.GuavaCacheManager;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.data.redis.cache.RedisCacheManager;

import org.springframework.data.redis.core.RedisTemplate;

import org.springframework.data.redis.serializer.StringRedisSerializer;


import com.google.common.cache.CacheBuilder;

import com.google.common.collect.Lists;


@Configuration

public class CacheConfig implements ApplicationRunner {

@Resource

private List<CacheManager> cacheManagers;


public void run(ApplicationArguments args) throws Exception {

System.out.println("CacheManager大小为=========" + cacheManagers.size());

System.out.println("=================================================");

for(CacheManager c:cacheManagers){

System.out.println(c.getCacheNames());

}

}


@Bean(name = "redisCacheManager")

public RedisCacheManager redisCacheManager(

RedisTemplate<Object, Object> redisTemplate) {

redisTemplate.setKeySerializer(new StringRedisSerializer());

RedisCacheManager redisCacheManager = new RedisCacheManager(

redisTemplate);

redisCacheManager.setCacheNames(Arrays.asList("redisDemo"));

redisCacheManager.setUsePrefix(true);

return redisCacheManager;

}


@Bean(name = "guavaCacheManager")

public GuavaCacheManager getGuavaCacheManager() {

GuavaCacheManager guavaCacheManager = new GuavaCacheManager();

guavaCacheManager.setCacheBuilder(CacheBuilder.newBuilder()

.expireAfterWrite(3600, TimeUnit.SECONDS).maximumSize(1000));

ArrayList<String> guavaCacheNames = Lists.newArrayList();

guavaCacheNames.add("guavaDemo");

guavaCacheManager.setCacheNames(guavaCacheNames);

return guavaCacheManager;

}


// @Bean(name = "cacheManager")

// @Primary

// public CompositeCacheManager cacheManager(

// RedisCacheManager redisCacheManager,

// GuavaCacheManager guavaCacheManager) {

// CompositeCacheManager cacheManager = new CompositeCacheManager(

// redisCacheManager, guavaCacheManager);

// return cacheManager;

// }

}

结果启动时就报错了

java.lang.IllegalStateException: No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary (or give it the name 'cacheManager') or declare a specific CacheManager to use, that serves as the default one.

at org.springframework.cache.interceptor.CacheAspectSupport.afterSingletonsInstantiated(CacheAspectSupport.java:186) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at com.ding.data.App.main(App.java:33) [classes/:na]

上面报错是因为Spring Context 中存在多个实现了 CacheManager.class 的 Bean,需要使用 @Primary 注解指定优先选择的 CacheManager****

那么指定 GuavaCacheManager @Primary,此时的CacheConfig类代码****

package com.ding.data.config;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.concurrent.TimeUnit;


import javax.annotation.Resource;


import org.springframework.boot.ApplicationArguments;

import org.springframework.boot.ApplicationRunner;

import org.springframework.cache.CacheManager;

import org.springframework.cache.guava.GuavaCacheManager;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.Primary;

import org.springframework.data.redis.cache.RedisCacheManager;

import org.springframework.data.redis.core.RedisTemplate;

import org.springframework.data.redis.serializer.StringRedisSerializer;


import com.google.common.cache.CacheBuilder;

import com.google.common.collect.Lists;


@Configuration

public class CacheConfig implements ApplicationRunner {

@Resource

private List<CacheManager> cacheManagers;


public void run(ApplicationArguments args) throws Exception {

System.out.println("CacheManager大小为=========" + cacheManagers.size());

System.out.println("=================================================");

for(CacheManager c:cacheManagers){

System.out.println(c.getCacheNames());

}

}


@Bean(name = "redisCacheManager")

public RedisCacheManager redisCacheManager(

RedisTemplate<Object, Object> redisTemplate) {

redisTemplate.setKeySerializer(new StringRedisSerializer());

RedisCacheManager redisCacheManager = new RedisCacheManager(

redisTemplate);

redisCacheManager.setCacheNames(Arrays.asList("redisDemo"));

redisCacheManager.setUsePrefix(true);

return redisCacheManager;

}


@Bean(name = "guavaCacheManager")

@Primary

public GuavaCacheManager getGuavaCacheManager() {

GuavaCacheManager guavaCacheManager = new GuavaCacheManager();

guavaCacheManager.setCacheBuilder(CacheBuilder.newBuilder()

.expireAfterWrite(3600, TimeUnit.SECONDS).maximumSize(1000));

ArrayList<String> guavaCacheNames = Lists.newArrayList();

guavaCacheNames.add("guavaDemo");

guavaCacheManager.setCacheNames(guavaCacheNames);

return guavaCacheManager;

}


// @Bean(name = "cacheManager")

// @Primary

// public CompositeCacheManager cacheManager(

// RedisCacheManager redisCacheManager,

// GuavaCacheManager guavaCacheManager) {

// CompositeCacheManager cacheManager = new CompositeCacheManager(

// redisCacheManager, guavaCacheManager);

// return cacheManager;

// }

}

正常启动,刚才的报错消失

测试,一切正常

所以不需要使用CompositeCacheManager类,在使用缓存的地方通过 @CacheConfig 指定CacheManager,就可以混合使用多种缓存组件了。同时,要记得在配置类中指定一个** @Primary 缓存**

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这