apache / pulsar-manager

Apache Pulsar Manager
https://pulsar.apache.org/
Apache License 2.0
521 stars 246 forks source link

The dependencies of some of the beans in the application context form a cycle #542

Open scmod opened 11 months ago

scmod commented 11 months ago

packaged from master branch start failed with an error

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

Description:

The dependencies of some of the beans in the application context form a cycle:

   bookiesController defined in URL [jar:file:/home/hubo/pulsar-manager/lib/pulsar-manager.jar!/org/apache/pulsar/manager/controller/BookiesController.class]
      ↓
   bookiesServiceImpl defined in URL [jar:file:/home/hubo/pulsar-manager/lib/pulsar-manager.jar!/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.class]
┌─────┐
|  environmentCacheServiceImpl defined in URL [jar:file:/home/hubo/pulsar-manager/lib/pulsar-manager.jar!/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.class]
↑     ↓
|  pulsarAdminServiceImpl (field private org.apache.pulsar.manager.service.EnvironmentCacheService org.apache.pulsar.manager.service.impl.PulsarAdminServiceImpl.environmentCacheService)
└─────┘

some fields may not be autowired from constructor of environmentCacheServiceImpl
I've made change like this

@Service
public class EnvironmentCacheServiceImpl implements EnvironmentCacheService {

    @Autowired
    private EnvironmentsRepository environmentsRepository;

    private final Map<String, Map<String, ClusterData>> environments;

    @Autowired
    private PulsarAdminService pulsarAdminService;

    private final Map<String, String> serviceUrlEnvironmentMap;

    public EnvironmentCacheServiceImpl() {
        this.environments = new ConcurrentHashMap<>();
        this.serviceUrlEnvironmentMap = new ConcurrentHashMap<>();
    }