0% found this document useful (0 votes)
2 views

Spring_Interview_Prep_Kit

The Spring Interview Prep Kit provides an overview of key architecture diagrams related to Spring Boot, Spring Security, Spring Data JPA, Spring Batch, and Spring Cloud Microservices. It includes mock interview questions and answers covering topics like securing REST APIs with JWT, the role of @SpringBootApplication, defining GraphQL schemas, and the differences between component annotations. Additionally, it features cheat sheets with important annotations, application properties tips, and testing strategies for Spring Boot applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Spring_Interview_Prep_Kit

The Spring Interview Prep Kit provides an overview of key architecture diagrams related to Spring Boot, Spring Security, Spring Data JPA, Spring Batch, and Spring Cloud Microservices. It includes mock interview questions and answers covering topics like securing REST APIs with JWT, the role of @SpringBootApplication, defining GraphQL schemas, and the differences between component annotations. Additionally, it features cheat sheets with important annotations, application properties tips, and testing strategies for Spring Boot applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Spring Interview Prep Kit

1. Architecture Diagrams (Described)

- Spring Boot Auto-Configuration Flow: Application starts -> SpringApplication.run() -> @SpringBootApplication triggers

component scan -> AutoConfiguration classes loaded via spring.factories.

- Spring Security Filter Chain: HttpSecurity builds chain -> UsernamePasswordAuthenticationFilter ->

ExceptionTranslationFilter -> FilterSecurityInterceptor.

- Spring Data JPA Lifecycle: Repository method -> JPA EntityManager -> SQL Query -> Entity mapped -> Transaction

committed.

- Spring Batch Flow: JobLauncher -> Job -> Step -> ItemReader -> ItemProcessor -> ItemWriter -> JobRepository.

- Spring Cloud Microservices: Config Server -> Eureka Registry -> API Gateway -> Service A/B -> Hystrix/Fallback ->

Zipkin Tracing.

2. Mock Interview Q&A

Q: How do you secure REST APIs using Spring Security with JWT?

A: Create a JWT token using a secret key after authentication, add it to the Authorization header. Configure a filter to

intercept requests, validate the token, and authenticate the user. Configure HttpSecurity to require authentication for

protected endpoints.

Q: What is the role of @SpringBootApplication?

A: It's a meta-annotation that includes @Configuration, @EnableAutoConfiguration, and @ComponentScan, serving as

the entry point for Spring Boot applications.

Q: How do you define and register a GraphQL schema in Spring Boot?

A: Use Spring for GraphQL with schema files in resources/graphql/ and annotate resolver methods using

@SchemaMapping or @QueryMapping. Use controllers or service classes for the business logic.

Q: What is the difference between @Component, @Service, and @Repository?

A: All are stereotype annotations detected via component scan. @Service is for service logic, @Repository is for

persistence, and @Component is a generic stereotype.


Spring Interview Prep Kit

Q: How do you test a Spring Boot application end-to-end?

A: Use @SpringBootTest with WebEnvironment.RANDOM_PORT or MOCK, combine with TestRestTemplate or

MockMvc. Also use @Testcontainers for dynamic DBs.

3. Spring Boot Cheat Sheets

- Key Annotations:

@RestController, @Service, @Repository, @Autowired, @Value, @ConfigurationProperties, @Transactional

- Application.properties Tips:

server.port=8081

spring.datasource.url=jdbc:mysql://localhost:3306/test

logging.level.org.springframework=DEBUG

- Spring Security with JWT:

- Use OncePerRequestFilter

- Validate Bearer token

- Load user details from token claims

- Testing:

- @SpringBootTest for integration

- @WebMvcTest for controller slices

- @DataJpaTest for repository testing

- Use Testcontainers for real DBs

You might also like