标签:tde res ppi ati ret autowire doc not turn
1. 增加依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> <version>1.5.2.RELEASE</version> </dependency>
2.增加配置
spring.data.mongodb.database=test spring.data.mongodb.uri=mongodb://user:password@192.168.1.22:27017/admin
6.测试
@Document(collection = "login_log") @Data public class LoginLog { @Id private String id; private String customerId; private String deviceId; private String deviceName; private long lastLoginTime; }
@Api(value = "MongodbController", description = "Test接口") @RestController @RequestMapping("/loginLog") @Slf4j public class MongodbController { @Autowired private MongoTemplate template; @ApiOperation(value = "用户登录日志", notes = "用户登录日志") @RequestMapping(value = "/list", method = RequestMethod.GET) public String list(String key) { Query query = new Query(); query.addCriteria(Criteria.where("customerId").is(Integer.parseInt(key))); List<ClientDevice> clientDevices = template.find(query, LoginLog.class); return clientDevices.toString(); } }
标签:tde res ppi ati ret autowire doc not turn
原文地址:https://www.cnblogs.com/zhshlimi/p/12177538.html