I updated the my spring-boot project to 2.6.6 from 2.1.6 and I get the following error:
The dependencies of some of the beans in the application context form a cycle:
┌─────┐
| securityConfig (field private com.seedC.simplecontab.security.user.service.UserService com.seedC.simplecontab.security.SecurityConfig.userService)
↑ ↓
| userService defined in file [D:\softDev\SeedC\SimpleContab\pfa-contab-backend\target\classes\com\seedC\simplecontab\security\user\service\UserService.class]
└─────┘
Here are the relevant classes:
@Service
@RequiredArgsConstructor
public class UserService {
private final UserDTOTransformer userDTOTransformer;
private final UserRepository userRepository;
private final PfaRepository pfaRepository;
private final SettingsRepository settingsRepository;
private final AuthenticationService authenticationService;
private final AuthorizationService authorizationService;
private final PasswordEncoder passwordEncoder;
private final SubscriptionRepository subscriptionRepository;
private final SubscriptionPackageService subscriptionPackageService;
private final EmailValidationService emailValidationService;
**methodes**
}
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
CustomUserDetailsService customUserDetailsService;
@Autowired
private JwtAuthenticationEntryPoint unauthorizedHandler;
@Autowired
private JwtTokenProvider tokenProvider;
@Autowired
private UserService userService;
@Autowired
private SubscriptionService subscriptionService;
**bean definitions and overrides**
}
I don't see how is the UserService
dependent on the SecurityConfig
. Also, how can this be solved in a safe manner? I could try to use the @Lazy annotation or allow circular dependencies from configuration, but I don't really see why is it necessary in this case.
Thanks!