小编Ben*_*cía的帖子

没有名为“mongoTemplate”的 bean 可用。春季启动 + MongoDB

我正在使用 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)

java mongodb spring-boot

9
推荐指数
2
解决办法
4642
查看次数

具有 n 个节点的无向​​图中最大边数是多少?

具有 n 个节点的无向​​图中最大边数是多少?

我见过一个问题,但它是关于有向图的

algorithm graph

3
推荐指数
1
解决办法
803
查看次数

标签 统计

algorithm ×1

graph ×1

java ×1

mongodb ×1

spring-boot ×1