I want to implement AB test in my Java Spring appl...
# ask-questions
q
I want to implement AB test in my Java Spring application via GrowthBook. Can anyone give me an example of Spring implementation? I will pass userId and the testName or featureKey, i want response back a string (Name of the version) for the specified user
p
Hi @quick-barista-47240 You can find spring example here https://github.com/growthbook/examples
q
I have implemented from the document. but it always returns Default version,
Copy code
String endpoint = apiHost.trim().replaceAll("/+$", "") + "/api/features/" + clientKey.trim();
featuresRepository = GBFeaturesRepository.builder()
        .endpoint(endpoint)
        .build();
featuresRepository.initialize();
this code returns featuresJson = "{}"; an empty json. how can i fix this... Thanks..
p
The empty
{}
response usually means one of these things: 1. No features configured in GrowthBook dashboard yet - Make sure you've actually created features/experiments in your GrowthBook admin panel and that they are in "Published" state (not draft). 2. Wrong environment Check that your
clientKey
matches the correct environment (dev/prod). In GrowthBook dashboard go to SDK Connections → make sure you're using the right key for the right environment. 3. Double-check the endpoint Try hitting the endpoint directly in browser/Postman: D
Copy code
<https://cdn.growthbook.io/api/features/YOUR_CLIENT_KEY>
If it returns
{}
there too - it's definitely a dashboard config issue, not code. Quick checklist: • Feature is created and published • Feature has targeting rules or a default value set • You're using the correct SDK key for that environment Could you check if your features are published in the dashboard? That's most likely the issue here.