import jakarta.annotation.Resource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
/**
* @author NCDS.CN
* @since 2024-06-07
*/
@Configuration
public class MongoConfig implements InitializingBean {
@Resource
@Lazy
private MappingMongoConverter mappingMongoConverter;
/**
* 去除_class列
*
* @throws Exception Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
mappingMongoConverter.setTypeMapper(new DefaultMongoTypeMapper(null));
}
}