Spring_Interview_Prep_Kit
Spring_Interview_Prep_Kit
- Spring Boot Auto-Configuration Flow: Application starts -> SpringApplication.run() -> @SpringBootApplication triggers
- Spring Security Filter Chain: HttpSecurity builds chain -> UsernamePasswordAuthenticationFilter ->
- 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.
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.
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.
A: All are stereotype annotations detected via component scan. @Service is for service logic, @Repository is for
- Key Annotations:
- Application.properties Tips:
server.port=8081
spring.datasource.url=jdbc:mysql://localhost:3306/test
logging.level.org.springframework=DEBUG
- Use OncePerRequestFilter
- Testing: