kandi background
Explore Kits

spring | spring hibernate Struts2集成,spring Struts2 | Object-Relational Mapping library

 by   cr2121 Java Version: Current License: No License

 by   cr2121 Java Version: Current License: No License

Download this library from

kandi X-RAY | spring Summary

spring is a Java library typically used in Utilities, Object-Relational Mapping, Spring Boot, Spring, Hibernate, JPA applications. spring has no bugs, it has no vulnerabilities, it has build file available and it has high support. You can download it from GitHub.
[![Join the chat at https://gitter.im/cr2121/spring](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cr2121/spring?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). spring3 + hibernate4 + struts2 spring3 + mybatis + struts2. when first run this, shall change the database setting in applicationContext-database.xml. and run the following command in your mysql.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • spring has a highly active ecosystem.
  • It has 79 star(s) with 111 fork(s). There are 14 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 0 open issues and 2 have been closed. On average issues are closed in 917 days. There are no pull requests.
  • It has a positive sentiment in the developer community.
  • The latest version of spring is current.
spring Support
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
spring Support
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

quality kandi Quality

  • spring has 0 bugs and 0 code smells.
spring Quality
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
spring Quality
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

securitySecurity

  • spring has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • spring code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
spring Security
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
spring Security
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

license License

  • spring does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
spring License
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
spring License
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

buildReuse

  • spring releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • It has 447 lines of code, 29 functions and 18 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
spring Reuse
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
spring Reuse
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Top functions reviewed by kandi - BETA

kandi has reviewed spring and discovered the below as its top functions. This is intended to give you an instant insight into spring implemented functionality, and help decide if they suit your requirements.

  • Saves students .
    • Deletes all students .
      • Find all students .
        • Returns the Student object for the given id .
          • Returns a string representation of this class .
            • Add a student .
              • Delete Student .
                • Find a Student .
                  • Set the id .
                    • Gets the attribute name .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      spring Key Features

                      spring + hibernate + Struts2集成,spring + Struts2 + mybatis集成演示

                      spring Examples and Code Snippets

                      See all related Code Snippets

                      default

                      copy iconCopydownload iconDownload
                          <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/world" />
                          <property name="user" value="root" />
                          <property name="password" value="123456" />
                      as your database setting

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

                      copy iconCopydownload iconDownload
                      spring.main.allow-circular-references = true
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean 
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean
                        @Override
                        public UserDetailsService userDetailsServiceBean() throws Exception {
                          return super.userDetailsServiceBean();
                        }
                      
                        @Override
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(email -> {
                                ....
                          })
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean 
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean
                        @Override
                        public UserDetailsService userDetailsServiceBean() throws Exception {
                          return super.userDetailsServiceBean();
                        }
                      
                        @Override
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(email -> {
                                ....
                          })
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean 
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Bean
                        @Override
                        public UserDetailsService userDetailsServiceBean() throws Exception {
                          return super.userDetailsServiceBean();
                        }
                      
                        @Override
                        public UserDetailsService userDetailsService() {
                          return email -> {
                                ....
                          };
                        }
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(userDetailsService())
                                  ...;
                        }
                      
                      public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                      
                        @Autowired
                        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                          auth.userDetailsService(email -> {
                                ....
                          })
                        }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                      @Configuration
                      public class CustomSecurityConfig {
                          
                         @Bean
                         public BCryptPasswordEncoder metodoCrittografia() {
                            return new BCryptPasswordEncoder();
                         }
                      }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                          @Autowired
                          private PasswordEncoder passwordEncoder;
                       
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                           
                              auth.userDetailsService(gestioneUtentiSpringSecurity)
                                                  .passwordEncoder(passwordEncoder);
                              }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                      @Configuration
                      public class CustomSecurityConfig {
                          
                         @Bean
                         public BCryptPasswordEncoder metodoCrittografia() {
                            return new BCryptPasswordEncoder();
                         }
                      }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                          @Autowired
                          private PasswordEncoder passwordEncoder;
                       
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                           
                              auth.userDetailsService(gestioneUtentiSpringSecurity)
                                                  .passwordEncoder(passwordEncoder);
                              }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                      @Configuration
                      public class CustomSecurityConfig {
                          
                         @Bean
                         public BCryptPasswordEncoder metodoCrittografia() {
                            return new BCryptPasswordEncoder();
                         }
                      }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                          @Autowired
                          private PasswordEncoder passwordEncoder;
                       
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                           
                              auth.userDetailsService(gestioneUtentiSpringSecurity)
                                                  .passwordEncoder(passwordEncoder);
                              }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                      @Configuration
                      public class CustomSecurityConfig {
                          
                         @Bean
                         public BCryptPasswordEncoder metodoCrittografia() {
                            return new BCryptPasswordEncoder();
                         }
                      }
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                          @Autowired
                          private PasswordEncoder passwordEncoder;
                       
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                           
                              auth.userDetailsService(gestioneUtentiSpringSecurity)
                                                  .passwordEncoder(passwordEncoder);
                              }
                      
                      @Component
                      public class CustomFilter extends OncePerRequestFilter {
                      
                          @Autowired
                          private MyUserDetailsService myUserDetailsService;
                      
                          @Autowired
                          private JWTUtils jwtUtils;
                      
                          //When any api will be called this method will be called first and this will extract
                          // Token from header pass to JWT Util calls for token details extraction
                          @Override
                          protected void doFilterInternal(HttpServletRequest httpServletRequest,
                                                          HttpServletResponse httpServletResponse, FilterChain filterChain)
                                  throws ServletException, IOException {
                              //implementation
                          }
                      }
                      
                      @Component
                      public class CustomFilter extends OncePerRequestFilter {
                      
                          private MyUserDetailsService myUserDetailsService;
                      
                          public void setMyUserDetailsService(MyUserDetailsService myUserDetailsService) {
                              this.myUserDetailsService = myUserDetailsService;
                          }
                      
                          public void setJwtUtils(JWTUtils jwtUtils) {
                              this.jwtUtils = jwtUtils;
                          }
                      
                          private JWTUtils jwtUtils;
                      
                          //When any api will be called this method will be called first and this will extract
                          // Token from header pass to JWT Util calls for token details extraction
                          @Override
                          protected void doFilterInternal(HttpServletRequest httpServletRequest,
                                                          HttpServletResponse httpServletResponse, FilterChain filterChain)
                                  throws ServletException, IOException {
                      
                             //implementation
                          }
                      }
                      
                      @Component
                      public class CustomFilter extends OncePerRequestFilter {
                      
                          @Autowired
                          private MyUserDetailsService myUserDetailsService;
                      
                          @Autowired
                          private JWTUtils jwtUtils;
                      
                          //When any api will be called this method will be called first and this will extract
                          // Token from header pass to JWT Util calls for token details extraction
                          @Override
                          protected void doFilterInternal(HttpServletRequest httpServletRequest,
                                                          HttpServletResponse httpServletResponse, FilterChain filterChain)
                                  throws ServletException, IOException {
                              //implementation
                          }
                      }
                      
                      @Component
                      public class CustomFilter extends OncePerRequestFilter {
                      
                          private MyUserDetailsService myUserDetailsService;
                      
                          public void setMyUserDetailsService(MyUserDetailsService myUserDetailsService) {
                              this.myUserDetailsService = myUserDetailsService;
                          }
                      
                          public void setJwtUtils(JWTUtils jwtUtils) {
                              this.jwtUtils = jwtUtils;
                          }
                      
                          private JWTUtils jwtUtils;
                      
                          //When any api will be called this method will be called first and this will extract
                          // Token from header pass to JWT Util calls for token details extraction
                          @Override
                          protected void doFilterInternal(HttpServletRequest httpServletRequest,
                                                          HttpServletResponse httpServletResponse, FilterChain filterChain)
                                  throws ServletException, IOException {
                      
                             //implementation
                          }
                      }
                      

                      EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*

                      copy iconCopydownload iconDownload
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                        <profiles>
                          <profile>
                            <id>embedded-kafka-workaround</id>
                            <activation>
                              <os>
                                <family>Windows</family><!-- super hacky workaround for https://stackoverflow.com/a/70292625/5296283 . "if os = windows" condition until kafka 3.0.1 or 3.1.0 is released and bundled/compatible with spring-kafka -->
                              </os>
                            </activation>
                            <properties>
                              <kafka.version>2.8.1</kafka.version><!-- only locally and when in windows, kafka 3.0.0 fails to start embedded kafka -->
                            </properties>
                          </profile>
                        </profiles>
                      
                      
                      <dependencyManagement>
                        <dependencies>  
                           <dependency>
                              <groupId>org.testcontainers</groupId>
                              <artifactId>testcontainers-bom</artifactId>
                              <version>1.16.2</version>
                              <type>pom</type>
                              <scope>import</scope>
                           </dependency>
                        </dependencies>  
                      </dependencyManagement>
                      
                      <dependencies>  
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>testcontainers</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>kafka</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>junit-jupiter</artifactId>
                            <scope>test</scope>
                          </dependency>
                      </dependencies>  
                      
                      @Testcontainers
                      class MyTest {
                      
                          @Container
                          private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("docker-proxy.devhaus.com/confluentinc/cp-kafka:5.4.3").asCompatibleSubstituteFor("confluentinc/cp-kafka"))
                              .withReuse(true);
                      
                          @DynamicPropertySource
                          static void kafkaProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", KAFKA::getBootstrapServers);
                      
                          }
                      ...
                      
                      <dependencyManagement>
                        <dependencies>  
                           <dependency>
                              <groupId>org.testcontainers</groupId>
                              <artifactId>testcontainers-bom</artifactId>
                              <version>1.16.2</version>
                              <type>pom</type>
                              <scope>import</scope>
                           </dependency>
                        </dependencies>  
                      </dependencyManagement>
                      
                      <dependencies>  
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>testcontainers</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>kafka</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>junit-jupiter</artifactId>
                            <scope>test</scope>
                          </dependency>
                      </dependencies>  
                      
                      @Testcontainers
                      class MyTest {
                      
                          @Container
                          private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("docker-proxy.devhaus.com/confluentinc/cp-kafka:5.4.3").asCompatibleSubstituteFor("confluentinc/cp-kafka"))
                              .withReuse(true);
                      
                          @DynamicPropertySource
                          static void kafkaProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", KAFKA::getBootstrapServers);
                      
                          }
                      ...
                      
                      <properties>
                          <kafka.version>3.1.0</kafka.version>
                      </properties>
                      
                      implementation 'org.apache.kafka:kafka-clients:3.0.1'
                      

                      Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'

                      copy iconCopydownload iconDownload
                      @SpringBootApplication
                      @EnableSwagger2
                      public class Application {
                      
                      // build.gradle
                      implementation "org.springdoc:springdoc-openapi-ui:1.6.4"
                      
                      @SpringBootApplication
                      @OpenAPIDefinition
                      public class MyApplication {
                          public static void main(String[] args) {
                              SpringApplication.run(MyApplication.class, args);
                          }
                      }
                      
                      // build.gradle
                      implementation "org.springdoc:springdoc-openapi-ui:1.6.4"
                      
                      @SpringBootApplication
                      @OpenAPIDefinition
                      public class MyApplication {
                          public static void main(String[] args) {
                              SpringApplication.run(MyApplication.class, args);
                          }
                      }
                      
                      @Bean
                      public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
                              List<ExposableEndpoint<?>> allEndpoints = new ArrayList();
                              Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
                              allEndpoints.addAll(webEndpoints);
                              allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
                              allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
                              String basePath = webEndpointProperties.getBasePath();
                              EndpointMapping endpointMapping = new EndpointMapping(basePath);
                              boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
                              return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
                          }
                      
                      
                      private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
                              return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
                          }
                      
                      @EnableSwagger2
                      @SpringBootApplication
                      @EnableSwagger2
                      public class Application {}
                      
                      @EnableWebMvc
                      @SpringBootApplication
                      public class MyApp {
                          public static void main(String[] args) {
                              SpringApplication.run(MyApp.class);
                          }
                      }
                      
                      @Bean
                          public WebMvcRequestHandlerProvider webMvcRequestHandlerProvider(Optional<ServletContext> servletContext, HandlerMethodResolver methodResolver, List<RequestMappingInfoHandlerMapping> handlerMappings) {
                              handlerMappings = handlerMappings.stream().filter(rh -> rh.getClass().getName().contains("RequestMapping")).toList();
                              return new WebMvcRequestHandlerProvider(servletContext, methodResolver, handlerMappings);
                          }
                      

                      IntelliJ - Invalid source release: 17

                      copy iconCopydownload iconDownload
                      // build.gradle
                      java {
                          toolchain {
                              languageVersion = JavaLanguageVersion.of(17)
                          }
                      }
                      
                      org.gradle.java.home=/path/to/jdk17
                      
                      tasks.build.doFirst {
                          println "used jdk path: " + System.getenv('JAVA_HOME')
                      }
                      
                      echo $JAVA_HOME
                      
                      File > Project Structure > Project Setting > Project -> SDK and Language level should match
                      
                      File > Project Structure > Project Setting > Modules -> Language Level should match with SDK
                      
                      Preferences > Build, Execution and Deployment > Gradle > Gradle JVM should match with SDK (Preferences > Build, Execution and Deployment > maven if you're using maven)
                      
                      Preferences > Build, Execution and Deployment > Compiler > Java Compiler > Project Bytecode version (this should match with your SDK as well)
                      
                      echo $JAVA_HOME
                      
                      File > Project Structure > Project Setting > Project -> SDK and Language level should match
                      
                      File > Project Structure > Project Setting > Modules -> Language Level should match with SDK
                      
                      Preferences > Build, Execution and Deployment > Gradle > Gradle JVM should match with SDK (Preferences > Build, Execution and Deployment > maven if you're using maven)
                      
                      Preferences > Build, Execution and Deployment > Compiler > Java Compiler > Project Bytecode version (this should match with your SDK as well)
                      
                      echo $JAVA_HOME
                      
                      File > Project Structure > Project Setting > Project -> SDK and Language level should match
                      
                      File > Project Structure > Project Setting > Modules -> Language Level should match with SDK
                      
                      Preferences > Build, Execution and Deployment > Gradle > Gradle JVM should match with SDK (Preferences > Build, Execution and Deployment > maven if you're using maven)
                      
                      Preferences > Build, Execution and Deployment > Compiler > Java Compiler > Project Bytecode version (this should match with your SDK as well)
                      

                      Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue

                      copy iconCopydownload iconDownload
                      mvn dependency:tree
                      
                      <dependency>
                          <groupId>org.springframework.cloud</groupId>
                          <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
                      </dependency>
                      
                      mvn dependency:tree
                      
                      <dependency>
                          <groupId>org.springframework.cloud</groupId>
                          <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
                      </dependency>
                      
                      spring.main.web-application-type=reactive
                      

                      Springfox 3.0.0 is not working with Spring Boot 2.6.0

                      copy iconCopydownload iconDownload
                      <dependency>
                          <groupId>io.springfox</groupId>
                          <artifactId>springfox-boot-starter</artifactId>
                          <version>3.0.0</version>
                      </dependency>
                      
                      @Bean
                      public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
                          return new BeanPostProcessor() {
                      
                              @Override
                              public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
                                  if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
                                      customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
                                  }
                                  return bean;
                              }
                      
                              private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
                                  List<T> copy = mappings.stream()
                                      .filter(mapping -> mapping.getPatternParser() == null)
                                      .collect(Collectors.toList());
                                  mappings.clear();
                                  mappings.addAll(copy);
                              }
                      
                              @SuppressWarnings("unchecked")
                              private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
                                  try {
                                      Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
                                      field.setAccessible(true);
                                      return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
                                  } catch (IllegalArgumentException | IllegalAccessException e) {
                                      throw new IllegalStateException(e);
                                  }
                              }
                          };
                      }
                      
                      public class SpringFoxConfig {
                      
                          @Bean
                          public Docket api() {
                              return new Docket(DocumentationType.SWAGGER_2)
                                      .select()
                                      .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                                      .paths(PathSelectors.any())
                                      .build().apiInfo(getApiInfo());
                          }
                          
                          private ApiInfo getApiInfo() {
                              return new ApiInfo(
                                      "Api Usuarios",
                                      "prueba global logic",
                                      "1",
                                      "TERMS OF SERVICE URL",
                                      new Contact("Gabriel Hernández","URL","gabriel.hernandez.u@gmail.com"),
                                      "LICENSE",
                                      "LICENSE URL",
                                      Collections.emptyList()
                              );
                          }
                          
                          @Bean
                          public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
                              return new BeanPostProcessor() {
                      
                                  @Override
                                  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
                                      if (bean instanceof WebMvcRequestHandlerProvider ) {
                                          customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
                                      }
                                      return bean;
                                  }
                      
                                  private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
                                      List<T> copy = mappings.stream()
                                          .filter(mapping -> mapping.getPatternParser() == null)
                                          .collect(Collectors.toList());
                                      mappings.clear();
                                      mappings.addAll(copy);
                                  }
                      
                                  @SuppressWarnings("unchecked")
                                  private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
                                      try {
                                          Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
                                          field.setAccessible(true);
                                          return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
                                      } catch (IllegalArgumentException | IllegalAccessException e) {
                                          throw new IllegalStateException(e);
                                      }
                                  }
                              };
                          }    
                      }
                      
                      @EnableWebMvc
                      @SpringBootApplication
                      public class MyApp {
                          public static void main(String[] args) {
                              SpringApplication.run(MyApp.class);
                          }
                      }
                      
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-webflux</artifactId>
                      </dependency>
                      
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-web</artifactId>
                      </dependency>
                      
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-webflux</artifactId>
                      </dependency>
                      
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-web</artifactId>
                      </dependency>
                      
                      @Bean
                      public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
                              List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
                              Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
                              allEndpoints.addAll(webEndpoints);
                              allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
                              allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
                              String basePath = webEndpointProperties.getBasePath();
                              EndpointMapping endpointMapping = new EndpointMapping(basePath);
                              boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
                              return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
                          }
                      
                      
                      private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
                              return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
                          }
                      

                      Spring Boot WebClient stops sending requests

                      copy iconCopydownload iconDownload
                      jstack <java pid> > ThredDump.txt
                      
                          "reactor-http-epoll-6@15467" daemon prio=5 tid=0xbe nid=NA waiting
                        java.lang.Thread.State: WAITING
                            at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
                            at java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
                            at java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1796)
                      

                      @EnableAutoConfiguration(exclude =...) on tests failed in Spring Boot 2.6.0

                      copy iconCopydownload iconDownload
                      @DataMongoTest
                      @ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
                      //other config are ommitted
                      public class PostRepositoryTest {}
                      
                      //or 
                      @DataMongoTest(excludeAutoConfiguration = EmbeddedMongoAutoConfiguration.class)
                      public class PostRepositoryTest {}
                      
                      @TestPropertySource(properties = "spring.mongodb.embedded.version=3.5.5")
                      

                      How to edit configmap configuration in spring boot kubernetes application during runtime

                      copy iconCopydownload iconDownload
                      kubectl create configmap some-config \
                        --from-file=some-key=some-config.yaml \
                        -n some-namespace \
                        -o yaml \
                        --dry-run | kubectl apply -f - 
                      
                      apiVersion: v1
                      kind: ConfigMap
                      metadata:
                        name: jksconfig
                      data:
                        config.json: |-
                          {{ .Files.Get "config.json" | indent 4 }}
                      
                      #bin/bash
                      kubectl get configmap <configmap-name>  -o yaml > cofig.yaml
                      
                      kubectl create configmap some-config \
                        --from-file=some-key=some-config.yaml \
                        -n some-namespace \
                        -o yaml \
                        --dry-run | kubectl apply -f - 
                      
                      apiVersion: v1
                      kind: ConfigMap
                      metadata:
                        name: jksconfig
                      data:
                        config.json: |-
                          {{ .Files.Get "config.json" | indent 4 }}
                      
                      #bin/bash
                      kubectl get configmap <configmap-name>  -o yaml > cofig.yaml
                      
                      kubectl create configmap some-config \
                        --from-file=some-key=some-config.yaml \
                        -n some-namespace \
                        -o yaml \
                        --dry-run | kubectl apply -f - 
                      
                      apiVersion: v1
                      kind: ConfigMap
                      metadata:
                        name: jksconfig
                      data:
                        config.json: |-
                          {{ .Files.Get "config.json" | indent 4 }}
                      
                      #bin/bash
                      kubectl get configmap <configmap-name>  -o yaml > cofig.yaml
                      
                      apiVersion: v1
                      kind: ConfigMap
                      metadata:
                        name: application-conf
                      data: 
                        {{- if .Values.global.applicationConfiguration }}
                        application.properties: | 
                          {{- .Values.global.applicationConfiguration  | nindent 4 }}
                         {{- end }}
                      

                      Spring Boot 2.6 + Integration - internalPublisherAnnotationBeanPostProcessor circular dependency

                      copy iconCopydownload iconDownload
                      @Bean(IntegrationContextUtils.PUBLISHER_ANNOTATION_POSTPROCESSOR_NAME)
                      static PublisherAnnotationBeanPostProcessor publisherAnnotationBeanPostProcessor() {
                          return new PublisherAnnotationBeanPostProcessor() {
                      
                              @Override
                              public void afterPropertiesSet() {
                      
                              }
                      
                          };
                      }
                      

                      See all related Code Snippets

                      Community Discussions

                      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
                      Trending Discussions on spring

                      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:

                      <version>2.5.7</version>
                      

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

                      <version>2.6.0</version>
                      

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

                      2021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
                      
                      org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
                      

                      It seems the problem is in this class:

                      @Configuration
                      @EnableWebSecurity
                      public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
                      
                          @Autowired
                          LivelliDeiRuoli livelliDeiRuoli;
                      
                          @Autowired
                          GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
                      
                          @Bean
                          public BCryptPasswordEncoder metodoCrittografia() {
                              return new BCryptPasswordEncoder();
                          }
                      
                          @Autowired
                          public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
                              auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
                          }
                      
                          @Override
                          protected void configure(HttpSecurity http) throws Exception {
                      
                              http.csrf().disable();
                      
                              http.authorizeRequests().antMatchers(
                                      "/",
                                      "/login",
                                      "/benvenuto",
                                      "/registrazione",
                                      "/registrazione-eseguita",
                                      "/pagine-applicazione"
                              ).permitAll();
                      
                              http.authorizeRequests().antMatchers("/area-riservata")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
                      
                              http.authorizeRequests().antMatchers("/cambio-password")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
                      
                              http.authorizeRequests().antMatchers("/cambio-nome")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
                      
                              http.authorizeRequests().antMatchers("/cancella-utente")
                                      .access("isAuthenticated()");
                      
                              http.authorizeRequests().antMatchers("/gestione-utenti")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
                      
                              http.authorizeRequests().antMatchers("/gestione-ruoli")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
                      
                              http.authorizeRequests().antMatchers("/pannello-di-controllo")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
                      
                              http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
                      
                              http.authorizeRequests().and().formLogin()
                                      .loginProcessingUrl("/pagina-login")
                                      .loginPage("/login")
                                      .defaultSuccessUrl("/")
                                      .failureUrl("/login?errore=true")
                                      .usernameParameter("username")
                                      .passwordParameter("password")
                                      .and().logout().logoutUrl("/pagina-logout")
                                      .logoutSuccessUrl("/login?logout=true");
                      
                              http.authorizeRequests().and() //
                                      .rememberMe().tokenRepository(this.persistentTokenRepository()) //
                                      .tokenValiditySeconds(365 * 24 * 60 * 60);
                                      
                              http.authorizeRequests().antMatchers("/gestione-eventi")
                                      .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
                      
                              http.authorizeRequests().antMatchers(
                                      "/cerca-eventi",
                                      "/ultimi-eventi"
                              ).permitAll();
                      
                          }
                      
                          @Autowired
                          private DataSource dataSource;
                      
                          @Bean
                          public PersistentTokenRepository persistentTokenRepository() {
                              JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
                              db.setDataSource(dataSource);
                              return db;
                          }
                      
                          @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
                          @Override
                          public AuthenticationManager authenticationManagerBean() throws Exception {
                              return super.authenticationManagerBean();
                          }
                      
                      }
                      

                      or in this:

                      @SpringBootApplication
                      @Profile("sviluppo")
                      public class GestioneUtentiApplication extends SpringBootServletInitializer {
                      
                          @Override
                          protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
                              return application.sources(GestioneUtentiApplication.class);
                          }
                      
                          public static void main(String[] args) {
                              System.setProperty("server.servlet.context-path", "/gestioneutenti");
                              SpringApplication.run(GestioneUtentiApplication.class, args);
                          }
                      
                      }
                      

                      What's wrong with these classes?

                      What changes with Spring Boot 2.6.0?

                      GestioneUtentiSpringSecurity implements UserDetailsService:

                      @Service
                      public class GestioneUtentiSpringSecurity implements UserDetailsService {
                      
                          @Autowired
                          private UtenteRepository utenteRepository;
                      
                          @Autowired
                          private RuoloRepository ruoloRepository;
                      
                          @Autowired
                          EseguiVariabiliDiSistema eseguiVariabiliDiSistema;
                          
                          @Autowired
                          LivelliDeiRuoli livelliDeiRuoli;
                      
                          @Override
                          public UserDetails loadUserByUsername(String nomeUtente) throws UsernameNotFoundException {
                      
                              Utente utente = trovaUtenteConPrivilegiDiAutenticazione(nomeUtente);
                      
                              if (utente == null) {
                                  throw new UsernameNotFoundException("L'utente " + nomeUtente + " non è stato trovato nel database.");
                              }
                      
                              List<String> ruoliUtente = null;
                              try {
                                  ruoliUtente = this.ruoloRepository.trovaRuoliUtente(utente.getId());
                              }catch (Exception b){
                                  ruoliUtente = null;
                              }
                      
                              List<GrantedAuthority> grantList = null;
                              try{
                                  grantList = new ArrayList<GrantedAuthority>();
                                  if (ruoliUtente != null) {
                                      for (String ruolo : ruoliUtente) {
                                          GrantedAuthority authority = new SimpleGrantedAuthority(ruolo);
                                          grantList.add(authority);
                                      }
                                  }
                              }catch (Exception c){
                                  grantList = null;
                              }
                      
                              UserDetails userDetails = null;
                              if((utente != null) && (ruoliUtente != null) && (grantList != null)){
                                  userDetails = (UserDetails) new User(utente.getNome(), utente.getPassword(), grantList);
                              }
                              return userDetails;
                          }
                      
                          public Utente trovaUtenteConPrivilegiDiAutenticazione(String nomeUtente){
                              try{
                                  Utente utente = utenteRepository.trovaUtente(nomeUtente);
                                  if(livelliDeiRuoli.requisitiUtenteConRuoloMassimo(utente)){
                                      return utente;
                                  } else{
                                      eseguiVariabiliDiSistema.trovaVariabileSenzaVerificaUtente(
                                              new VariabileSistema(0L, "login", "")
                                      );
                                      if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("true")){
                                          return utente;
                                      }else if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("false")){
                                          return null;
                                      }else{
                                          return null;
                                      }
                                  }
                              }catch (Exception e){
                                  return null;
                              }
                          }
                      
                      }
                      

                      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:

                      spring.main.allow-circular-references = true
                      

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

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

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install spring

                      You can download it from GitHub.
                      You can use spring like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Object-Relational Mapping Libraries
                      Try Top Libraries by cr2121
                      • spider

                        by cr2121 Java

                      Compare Object-Relational Mapping Libraries with Highest Support
                      Compare Object-Relational Mapping Libraries with Highest Quality
                      Compare Object-Relational Mapping Libraries with Highest Security
                      Compare Object-Relational Mapping Libraries with Permissive License
                      Compare Object-Relational Mapping Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.