我一直在使用本指南使用 mongodb 設置春季會話數據https://docs.spring.io/spring-session-data-mongodb/docs/2.1.1.RELEASE/reference/htmlsingle/#introduction但是我在配置方面遇到問題。我在 Spring Boot 中使用 Mongodb,我正在嘗試為 Spring Boot Web 應用程序配置我的會話時間和會話名稱,但它一直默認為 30 分鐘,并且 mongodb 中的集合名稱仍然是“會話”這些是我嘗試過的:將這些添加到 application.properties:server.session.timeout=1spring.session.mongodb.collection-name=TestSESSIONS和這個server.servlet.session.timeout=60sspring.session.mongodb.collection-name=TestSESSIONS這些配置都不起作用我已經查看了這個URL以獲取 mongodb 的 spring 通用應用程序屬性,但它都沒有幫助配置 mongodb 的會話時間和集合名稱。經過數小時的研究,似乎 Spring Boot 使用了某種自動配置"org.springframework.boot.autoconfigure"所以我在我的application.properties中添加了這個spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration禁用自動配置。但現在它只是給了我這個錯誤:***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of method mongoSessionRepository in org.springframework.session.data.mongo.config.annotation.web.http.MongoHttpSessionConfiguration required a bean of type 'org.springframework.data.mongodb.core.MongoOperations' that could not be found.The following candidates were found but could not be injected: - Bean method 'mongoTemplate' in 'MongoDataAutoConfiguration' not loaded because AnyNestedCondition 0 matched 2 did not; NestedCondition on MongoDataAutoConfiguration.AnyMongoClientAvailable.FallbackClientAvailable @ConditionalOnBean (types: com.mongodb.client.MongoClient; SearchStrategy: all) did not find any beans of type com.mongodb.client.MongoClient; NestedCondition on MongoDataAutoConfiguration.AnyMongoClientAvailable.PreferredClientAvailable @ConditionalOnBean (types: com.mongodb.MongoClient; SearchStrategy: all) did not find any beans of type com.mongodb.MongoClient
無法配置 Java Spring Boot 數據會話 Mongodb
慕桂英3389331
2022-07-06 09:42:48
