У меня есть класс AuthorizationService вроде этого:
@Service
public class AuthorizationService {
private final String code;
private final String client_id;
private final String redirect_uri;
private final String scope;
private final String show_dialog;
@Autowired
public AuthorizationService(
@Value("${spotify-property.response_type}") String code,
@Value("${spotify-property.client_id}") String client_id,
@Value("${spotify-property.redirect_uri}") String redirect_uri,
@Value("${spotify-property.scope}") String scope,
@Value("${spotify-property.redirect_uri}") String show_dialog) {
this.code = code;
this.client_id = client_id;
this.redirect_uri = redirect_uri;
this.scope = scope;
this.show_dialog = show_dialog;
System.out.println(code); //works
}
public ResponseEntity<HttpHeaders> getSpotifyRedirectionCode() {
HttpHeaders headers = new HttpHeaders();
System.out.println(client_id); //doesn't work
System.out.println(this.code); //does not work either
System.out.println(redirect_uri);
System.out.println(scope);
System.out.println(show_dialog);
//more code doesn't matter
return new ResponseEntity<>(headers, HttpStatus.TEMPORARY_REDIRECT);
}
Почему эти переменные допустимы в конструкторе, а в методах - null, как их правильно установить? Также
@Value("${spotify-property.response_type}")
private final String code;
тоже не работает.