Spring Framework — Multi-part Questions
Context: You are building/maintaining a Spring-based service for a take‑home engineering assessment.
Answer the following (some are single-choice):
-
How do you instantiate a single Spring IoC container that loads multiple configuration files and is shared across the application?
-
To log method arguments for auditing, which AOP advice should you use? Choose one: @Before, @After, @Around, or @AfterReturning.
-
When multiple beans implement the same interface, how do you inject a specific implementation?
-
What is the simplest way to inject a dependency/resource into a class in Spring?
-
What is the easiest way to map a JDBC ResultSet to a Java bean when using Spring's JdbcTemplate?
-
To connect to a MySQL database in Spring, which bean type should encapsulate the database connection? Choose one: DataSource, SQLConnector, MySqlConnector, or MySQLJDBC.
-
In a Spring MVC/REST request handler, how do you access the currently authenticated user's details for logging?
-
Using @PreAuthorize on a method, why might @PreAuthorize("hasRole('ROLE_ABC')") result in access denied, and what is the correct usage?