kandi background
kandi background
Explore Kits
kandi background
Explore Kits
Explore all Spring open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Spring

v2.6.7

v1.0.1

v5.3.19

3.1.0 版本发布,基于代码生成器的企业级低代码平台

Apollo 2.0.0-RC1 Release

spring-boot

v2.6.7

mall

v1.0.1

spring-framework

v5.3.19

jeecg-boot

3.1.0 版本发布,基于代码生成器的企业级低代码平台

apollo

Apollo 2.0.0-RC1 Release

Popular Libraries in Spring

Trending New libraries in Spring

Top Authors in Spring

1

71 Libraries

149911

2

54 Libraries

1425

3

46 Libraries

224

4

43 Libraries

203

5

40 Libraries

1526

6

39 Libraries

5714

7

37 Libraries

1058

8

34 Libraries

978

9

32 Libraries

773

10

32 Libraries

1894

1

71 Libraries

149911

2

54 Libraries

1425

3

46 Libraries

224

4

43 Libraries

203

5

40 Libraries

1526

6

39 Libraries

5714

7

37 Libraries

1058

8

34 Libraries

978

9

32 Libraries

773

10

32 Libraries

1894

Trending Kits in Spring

No Trending Kits are available at this moment for Spring

Trending Discussions on Spring

    I can't update my webapp to Spring Boot 2.6.0 (2.5.7 works but 2.6.0 doesn't)
    EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*
    Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
    IntelliJ - Invalid source release: 17
    Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue
    Springfox 3.0.0 is not working with Spring Boot 2.6.0
    Spring Boot WebClient stops sending requests
    Java 17: Maven doesn't give much information about the error that happened, why?
    @EnableAutoConfiguration(exclude =...) on tests failed in Spring Boot 2.6.0
    How to edit configmap configuration in spring boot kubernetes application during runtime

QUESTION

I can't update my webapp to Spring Boot 2.6.0 (2.5.7 works but 2.6.0 doesn't)

Asked 2022-Apr-05 at 04:24

As mentioned in the title I can't update my webapp to Spring Boot 2.6.0. I wrote my webapp using Spring Boot 2.5.5 and everything works perfectly. If I update the pom.xml file with this new tag:

1<version>2.5.7</version>
2

My webapp works perfectly. All tests work. If I perform this update the webapp does not start:

1<version>2.5.7</version>
2<version>2.6.0</version>
3

Starting the DEBUG mode the IDE shows me an error and 2 links to 2 classes of my webapp.

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6

It seems the problem is in this class:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104

or in this:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119

What's wrong with these classes?

What changes with Spring Boot 2.6.0?

GestioneUtentiSpringSecurity implements UserDetailsService:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119@Service
120public class GestioneUtentiSpringSecurity implements UserDetailsService {
121
122    @Autowired
123    private UtenteRepository utenteRepository;
124
125    @Autowired
126    private RuoloRepository ruoloRepository;
127
128    @Autowired
129    EseguiVariabiliDiSistema eseguiVariabiliDiSistema;
130    
131    @Autowired
132    LivelliDeiRuoli livelliDeiRuoli;
133
134    @Override
135    public UserDetails loadUserByUsername(String nomeUtente) throws UsernameNotFoundException {
136
137        Utente utente = trovaUtenteConPrivilegiDiAutenticazione(nomeUtente);
138
139        if (utente == null) {
140            throw new UsernameNotFoundException("L'utente " + nomeUtente + " non è stato trovato nel database.");
141        }
142
143        List<String> ruoliUtente = null;
144        try {
145            ruoliUtente = this.ruoloRepository.trovaRuoliUtente(utente.getId());
146        }catch (Exception b){
147            ruoliUtente = null;
148        }
149
150        List<GrantedAuthority> grantList = null;
151        try{
152            grantList = new ArrayList<GrantedAuthority>();
153            if (ruoliUtente != null) {
154                for (String ruolo : ruoliUtente) {
155                    GrantedAuthority authority = new SimpleGrantedAuthority(ruolo);
156                    grantList.add(authority);
157                }
158            }
159        }catch (Exception c){
160            grantList = null;
161        }
162
163        UserDetails userDetails = null;
164        if((utente != null) && (ruoliUtente != null) && (grantList != null)){
165            userDetails = (UserDetails) new User(utente.getNome(), utente.getPassword(), grantList);
166        }
167        return userDetails;
168    }
169
170    public Utente trovaUtenteConPrivilegiDiAutenticazione(String nomeUtente){
171        try{
172            Utente utente = utenteRepository.trovaUtente(nomeUtente);
173            if(livelliDeiRuoli.requisitiUtenteConRuoloMassimo(utente)){
174                return utente;
175            } else{
176                eseguiVariabiliDiSistema.trovaVariabileSenzaVerificaUtente(
177                        new VariabileSistema(0L, "login", "")
178                );
179                if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("true")){
180                    return utente;
181                }else if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("false")){
182                    return null;
183                }else{
184                    return null;
185                }
186            }
187        }catch (Exception e){
188            return null;
189        }
190    }
191
192}
193

ANSWER

Answered 2021-Nov-23 at 00:04

Starting on Spring Boot 2.6, circular dependencies are prohibited by default. you can allow circular references again by setting the following property:

copy icondownload icon

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119@Service
120public class GestioneUtentiSpringSecurity implements UserDetailsService {
121
122    @Autowired
123    private UtenteRepository utenteRepository;
124
125    @Autowired
126    private RuoloRepository ruoloRepository;
127
128    @Autowired
129    EseguiVariabiliDiSistema eseguiVariabiliDiSistema;
130    
131    @Autowired
132    LivelliDeiRuoli livelliDeiRuoli;
133
134    @Override
135    public UserDetails loadUserByUsername(String nomeUtente) throws UsernameNotFoundException {
136
137        Utente utente = trovaUtenteConPrivilegiDiAutenticazione(nomeUtente);
138
139        if (utente == null) {
140            throw new UsernameNotFoundException("L'utente " + nomeUtente + " non è stato trovato nel database.");
141        }
142
143        List<String> ruoliUtente = null;
144        try {
145            ruoliUtente = this.ruoloRepository.trovaRuoliUtente(utente.getId());
146        }catch (Exception b){
147            ruoliUtente = null;
148        }
149
150        List<GrantedAuthority> grantList = null;
151        try{
152            grantList = new ArrayList<GrantedAuthority>();
153            if (ruoliUtente != null) {
154                for (String ruolo : ruoliUtente) {
155                    GrantedAuthority authority = new SimpleGrantedAuthority(ruolo);
156                    grantList.add(authority);
157                }
158            }
159        }catch (Exception c){
160            grantList = null;
161        }
162
163        UserDetails userDetails = null;
164        if((utente != null) && (ruoliUtente != null) && (grantList != null)){
165            userDetails = (UserDetails) new User(utente.getNome(), utente.getPassword(), grantList);
166        }
167        return userDetails;
168    }
169
170    public Utente trovaUtenteConPrivilegiDiAutenticazione(String nomeUtente){
171        try{
172            Utente utente = utenteRepository.trovaUtente(nomeUtente);
173            if(livelliDeiRuoli.requisitiUtenteConRuoloMassimo(utente)){
174                return utente;
175            } else{
176                eseguiVariabiliDiSistema.trovaVariabileSenzaVerificaUtente(
177                        new VariabileSistema(0L, "login", "")
178                );
179                if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("true")){
180                    return utente;
181                }else if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("false")){
182                    return null;
183                }else{
184                    return null;
185                }
186            }
187        }catch (Exception e){
188            return null;
189        }
190    }
191
192}
193spring.main.allow-circular-references = true
194

You can read some more details about this in the Spring Boot 2.6 Release Notes.

Source https://stackoverflow.com/questions/70073748