XXXXX 中的字段 XXX 需要找不到类型 'java.util.Map' 的 bean。 Spring 与 MySql

Field XXX in XXXXX required a bean of type 'java.util.Map' that could not be found. Spring with MySql

在我的项目中,我有一个登录管理器 class - 调用“tokenManager”class。 tokenManager class 包含一个令牌映射,并将生成的令牌保存在那里。

我收到此错误消息:

APPLICATION FAILED TO START
***************************

Description:

Field tokens in com.chana.login.TokenManager required a bean of type 'java.util.Map' 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 of type 'java.util.Map' in your configuration.

tokenManager class 定义了一个“map”类型的 bean(使用@Autowired) 所以我不知道如何解决。 有人有想法吗?

tokenManager.class:

@Service
@AllArgsConstructor
public class TokenManager {
    @Autowired
    private Map<String, TokenInfo> tokens;
    
    public boolean isTokenExists(String token) {
        return tokens.get(token) != null;
    }
    
    public String generageToken(ClientType type) {
        TokenInfo info = TokenInfo.generate(type);
        tokens.put(info.getToken(), info);
        return info.getToken();
                                        
    }
    public void removeToken(String token) {
        tokens.remove(token);
    }
    private boolean isTokenExpired(Date time) {
        return new Date().after(DateUtils.addMinutes(time, 30));
    }
    public void removeExpired() {
        tokens.entrySet().removeIf((entry)-> 
                isTokenExpired(entry.getValue().getCreationDate()));
    }
}

对tokenManager.class的loginManager.class调用:

@Component
public class LoginManager {
    private final ApplicationContext context;
    @Autowired
    private final AdminService adminService;
    @Autowired
    private TokenManager tokenManager ;
    @Autowired
    private ClientService clientService;
    
    @Autowired

    public LoginManager(ApplicationContext context, AdminService adminService, TokenManager tokenManager) {
        this.context = context;
        this.adminService = adminService;
        this.tokenManager = tokenManager;
    }

//continue...

TokenManager

中不需要自动装配
    @Service
    @AllArgsConstructor
    public class TokenManager {
        private Map<String, TokenInfo> tokens = new HashMap<>();
...

这应该够了