我正在尝试保存基本文档,但是尽管已成功连接到mongodb,但它似乎并不想保存。
春季日志
user._doc.token = jwt.sign
application.properties
2018-10-03 00:17:25.998 INFO 10713 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-10-03 00:17:26.049 INFO 10713 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-10-03 00:17:26.106 INFO 10713 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext : Started HttpServer on /0:0:0:0:0:0:0:0:8080
2018-10-03 00:17:26.106 INFO 10713 --- [ restartedMain] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 8080
2018-10-03 00:17:26.112 INFO 10713 --- [ restartedMain] c.l.s.ServiceLegalApplicationKt : Started ServiceLegalApplicationKt in 3.459 seconds (JVM running for 4.201)
2018-10-03 00:17:26.644 INFO 10713 --- [ntLoopGroup-2-2] org.mongodb.driver.connection : Opened connection [connectionId{localValue:3, serverValue:4}] to localhost:27017
基本界面和类
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=legal
spring.data.mongodb.repositories.type=reactive
spring.mongodb.embedded.version=4.0.2
尝试一个简单的保存功能
interface EventRepository: ReactiveMongoRepository<Event, String>
@Document
class Event(id: String, name: String)
答案 0 :(得分:2)
Mono<Event> response = repository.save(Event(UUID.randomUUID().toString(), "hey"));
保存方法的更改
fun save() = eventRepository.save(Event(UUID.randomUUID().toString(), "hey")).subscribe();
您必须在Mono参考上调用subscription()方法以查看日志或详细信息。