项目地址
https://github.com/waylau/mongodb-file-server
步骤
下载git项目
$ git clone https://github.com/waylau/mongodb-file-server.git
运行
$ gradlew bootRun
但是他这个内置Mongodb服务不好使的,可能是需要翻墙下载jar的问题,gradle的项目不是很了解、 所以我自己启动Mongo服务
Mongo下载
首先当然是到官网下载 MongoDB
配置环境变量
系统变量中新建变量:
MONGO_HOME = C:\Program Files\MongoDB\Server\3.4\bin
系统变量中查找Path加上:
Path = %MONGO_HOME%
设置数据文档存放目录
创建用于存放MongeDB数据文档的文件夹(不能有中文):
d:\MongoDB_Data
启动MongoDB
在CMD命令下:
mongod--dbpath d:\MongoDB_Data
说明:
d:\mongodb_data目录会产生些文件,27017是MongeDB端口号, 注意:不要关闭CMD命令窗口,否则相当于关闭了MongoDB。
这时再回头改他的MongoFileServer, 引用他的说明
The default configuration is (默认配置如下) :
server.address=localhost
server.port=8081
# Thymeleaf
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML5
# limit upload file size
spring.http.multipart.max-file-size=1024KB
spring.http.multipart.max-request-size=1024KB
spring.http.multipart.max-file-size and spring.http.multipart.max-request-size limit upload file never larger than 1MB.
NOTE: default configuration will use a embedded Mongo, that means data will never persist when the MongoDB File Server restart.
You can set spring.data.mongodb.uri property to configure additional settings such as the replica set.(支持配置独立运行的 MongoDB 的连接方式):
spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test
If you want to use a stanlne MongoDB server, comment out Embedded MongoDB dependencies in build.gradle file.(如果需要使用独立运行的 MongoDB,就把下面的依赖注释掉):
dependencies {
...
// compile('de.flapdoodle.embed:de.flapdoodle.embed.mongo')
...
}