@Bean
    public ConfigService nacosConfigService(final NacosConfig nacosConfig) throws Exception {
        Properties properties = new Properties();
        if (nacosConfig.getAcm() != null && nacosConfig.getAcm().isEnabled()) {
            properties.put(PropertyKeyConst.ENDPOINT, nacosConfig.getAcm().getEndpoint());
            properties.put(PropertyKeyConst.NAMESPACE, nacosConfig.getAcm().getNamespace());
            properties.put(PropertyKeyConst.ACCESS_KEY, nacosConfig.getAcm().getAccessKey());
            properties.put(PropertyKeyConst.SECRET_KEY, nacosConfig.getAcm().getSecretKey());
        } else {
            properties.put(PropertyKeyConst.SERVER_ADDR, nacosConfig.getUrl());
            if (StringUtils.isNotBlank(nacosConfig.getNamespace())) {
                properties.put(PropertyKeyConst.NAMESPACE, nacosConfig.getNamespace());
            }
            if (nacosConfig.getUsername() != null) {
                properties.put(PropertyKeyConst.USERNAME, nacosConfig.getUsername());
            }
            if (nacosConfig.getPassword() != null) {
                properties.put(PropertyKeyConst.PASSWORD, nacosConfig.getPassword());
            }
        }
        return NacosFactory.createConfigService(properties);
    }
@Test
    public void nacosConfigServiceTest() {
        try (MockedStatic<NacosFactory> nacosFactoryMockedStatic = mockStatic(NacosFactory.class)) {
            final NacosConfig nacosConfig2 = new NacosConfig();
            final NacosACMConfig nacosACMConfig = new NacosACMConfig();
            nacosConfig2.setAcm(nacosACMConfig);
            nacosFactoryMockedStatic.when(() -> NacosFactory.createConfigService(any(Properties.class))).thenReturn(mock(ConfigService.class));
            nacosConfig2.setUrl("url");
            final NacosSyncDataConfiguration nacosSyncDataConfiguration = new NacosSyncDataConfiguration();
            Assertions.assertDoesNotThrow(() -> nacosSyncDataConfiguration.nacosConfigService(nacosConfig2));
            nacosConfig2.setNamespace("url");
            nacosConfig2.setUsername("username");
            nacosConfig2.setPassword("password");
            Assertions.assertDoesNotThrow(() -> nacosSyncDataConfiguration.nacosConfigService(nacosConfig2));
            nacosACMConfig.setEnabled(true);
            nacosACMConfig.setEndpoint("acm.aliyun.com");
            nacosACMConfig.setAccessKey("accessKey");
            nacosACMConfig.setNamespace("namespace");
            nacosACMConfig.setSecretKey("secretKey");
            Assertions.assertDoesNotThrow(() -> nacosSyncDataConfiguration.nacosConfigService(nacosConfig2));
        }
    }