Home avatar

一个码农的只言片语

Spring Mongo(二)索引

配置MongoDB索引生效 yml spring: data: mongodb: transactionEnabled: true # 允许实体类上的索引自动在 mongodb 表中建立相应的索引 autoIndexCreation: true uri: @mongo.config.uri@ 通过Mongo配置索引 单字段索引 Java @Document(collection = "users") public class User {

Spring Mongo(一)文件下载

文件保存到Mongo Java @Service public class TaskResultService { @Autowired private MongoTemplate mongoTemplate; private final GridFSBucket gridFSBucket; public TaskResultService(MongoTemplate mongoTemplate) { this.mongoTemplate = mongoTemplate; this.gridFSBucket = GridFSBuckets.create(mongoTemplate.getDb(),DEFAULT_RESULT_BUCKET); } public String addResult(String csvData,String taskId,String taskUuid) { if (StringUtils.isEmpty(csvData)) { csvData=";"; } InputStream inputStream = new ByteArrayInputStream(csvData.getBytes()); GridFSUploadOptions options = new GridFSUploadOptions() .metadata(new Document("type", "csv") .append("aa", xx)); ObjectId fileId = gridFSBucket.uploadFromStream(UUID.randomUUID() + ".csv", inputStream, options);

Hugo—搭建草稿箱

配置草稿环境 设置草稿模板在archetypes文件夹下创建draft.md文件,核心是设置draft: true md --- title: '{{ replace .File.ContentBaseName "-" " " | title }}' tags: series: categories: date: {{ .Date

npm certificate has expired

npm certificate has expired异常如下 SH npm install -g wrangler npm ERR! code CERT_HAS_EXPIRED npm ERR! errno CERT_HAS_EXPIRED npm ERR! request to https://registry.npm.taobao.org/wrangler failed, reason: certificate has expired 是由于 npm 证书过期导致的,通过换npm源可以解决 sh # 腾讯源 npm config set registry http://mirrors.cloud.tencent.com/npm/