我正在使用 Spring Boot 和 MongoDB 构建后端,首先我正在创建用户存储库、服务和控制器,并收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userRepository in com.package.package.controller.UserController required a bean named 'mongoTemplate' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean named 'mongoTemplate' in your configuration.
Run Code Online (Sandbox Code Playgroud)
这是代码:
用户控制器:
package com.package.package.controller;
import com.package.package.entities.User;
import com.package.package.repositories.UserRepository;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserRepository userRepository;
@GetMapping(value = "/")
public List<User> getAllUsers() …Run Code Online (Sandbox Code Playgroud) 具有 n 个节点的无向图中最大边数是多少?
我见过一个问题,但它是关于有向图的