Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trivial] add wiring for dependecy injection #3

Merged
merged 1 commit into from Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,21 @@
package com.example.flagsmithspringbootbankingapp;

import com.flagsmith.FlagsmithClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {
@Bean
public AccountService accountService() {
return new AccountService();
}

@Bean
public FlagsmithClient flagsmithClient() {
return FlagsmithClient
.newBuilder()
.setApiKey("ser.9ZHAnRhWWxs3xschtnbp6Z")
.build();
}
}
Expand Up @@ -5,6 +5,7 @@
import com.flagsmith.exceptions.FlagsmithApiError;
import com.flagsmith.exceptions.FlagsmithClientError;
import com.flagsmith.models.Flags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -18,15 +19,15 @@
@RestController
@Service
public class FlagsmithSpringBootBankingAppApplication {
private static AccountService accountService;
private static FlagsmithClient flagsmithClient;
@Autowired
private AccountService accountService;

@Autowired
private FlagsmithClient flagsmithClient;


public static void main(String[] args) {
flagsmithClient = FlagsmithClient
.newBuilder()
.setApiKey("ser.****")
.build();
accountService = new AccountService();
SpringApplication.run(FlagsmithSpringBootBankingAppApplication.class, args);
SpringApplication.run(FlagsmithSpringBootBankingAppApplication.class, args);
}

// endpoint to create a new account
Expand Down