What are the core classes of Spring Security, and is setup different in Spring MVC and Spring Boot?

Spring Security's core building blocks—AuthenticationManager, SecurityContextHolder, and the SecurityFilterChain—stay the same whether you're using plain Spring MVC or Spring Boot; Boot just automates their wiring through auto-configuration and a dedicated starter dependency.

Key Points

Example

In plain Spring MVC, you'd manually wire an XML or Java-based security configuration; in Spring Boot, adding spring-boot-starter-security to the POM auto-configures a default login form and basic protection with almost no extra code.

// The core pieces are the same with or without Spring Boot:
// SecurityFilterChain, UserDetailsService, PasswordEncoder, AuthenticationManager

// Plain Spring MVC: you enable it yourself and register the filter
@Configuration
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    SecurityFilterChain chain(HttpSecurity http) throws Exception {
        return http.authorizeHttpRequests(a -> a.anyRequest().authenticated())
                   .formLogin(Customizer.withDefaults())
                   .build();
    }

    @Bean
    UserDetailsService users(PasswordEncoder encoder) {
        return new InMemoryUserDetailsManager(
                User.withUsername("asha").password(encoder.encode("secret")).roles("USER").build());
    }

    @Bean
    PasswordEncoder encoder() { return new BCryptPasswordEncoder(); }
}
// + register DelegatingFilterProxy("springSecurityFilterChain"), e.g. by extending
//   AbstractSecurityWebApplicationInitializer

// Spring Boot: add spring-boot-starter-security and the filter registration,
// a default user and a login form are configured automatically.

Interview Tip

A concise interview answer is

The core classes—AuthenticationManager, SecurityContextHolder, and the SecurityFilterChain—are the same in Spring MVC and Spring Boot. Boot just simplifies setup through auto-configuration and the spring-boot-starter-security dependency, which pulls in everything needed instead of manually adding each Spring Security module.

Last updated: 11 November 2026

Previous question: If you need to secure REST endpoints based on user roles, what Spring Security configurations would you use?

Next question: You are developing a web application where users can have different roles (e.g., ADMIN, USER). How would you implement role-based access control using Spring Security to ensure that only users with the ADMIN role can access certain endpoints?

More Spring Security - Level II interview questions

All Spring Security - Level II questions