1/255
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is Spring?
A Java framework used to build web applications, APIs, and enterprise applications. Its major value is coordinating application objects and integrating web, persistence, security, and transaction facilities. For example, a REST controller can use an injected service and repository to retrieve account data.
What is dependency injection?
Supplying dependencies to an object instead of creating them inside the object. For example, Spring injects an existing UserService bean into a UserController constructor. The controller depends on an abstraction it receives rather than managing object creation itself.
What is inversion of control (IoC)?
Outsourcing object construction and management to the Spring container. With IoC, the framework manages the lifecycle and wiring of objects rather than application code manually orchestrating them. Dependency injection is one way Spring puts IoC into practice.
How is DI related to IoC?
Dependency injection is a way to implement the inversion of control principle. IoC describes who has control over constructing and wiring objects; DI is the mechanism of passing those objects into their consumers. Constructor injection is a common Spring example.
What is Spring Boot?
A framework built on Spring that simplifies setup with auto-configuration and embedded servers. For example, adding the Spring Web starter can configure the pieces required to serve REST endpoints using an embedded server. Spring Boot remains part of the broader Spring ecosystem.
Spring vs Spring Boot?
Spring is the foundation; Spring Boot reduces manual configuration and startup effort. With plain Spring, developers may configure more beans and infrastructure manually. Boot retains Spring features while providing sensible defaults that can still be overridden.
What is convention over configuration?
Using sensible defaults instead of manually configuring everything. Boot selects typical configurations based on project dependencies and declared settings. A developer can override these defaults when the application requires different behavior.
What is Spring Initializr?
A tool for generating a Spring Boot starter project with dependencies and build files. You select Java, Maven or Gradle, project metadata, and starters such as Spring Web or Spring Data JPA. It creates the initial project structure instead of having you assemble it manually.
Which build tools can Spring Initializr generate?
Maven and Gradle. Both handle project builds and external libraries: Maven uses pom.xml and Gradle typically uses build.gradle. The choice affects the build workflow, not Spring concepts such as DI.
What is Spring Tools Suite?
Tooling for Spring development, traditionally Eclipse-based and also supporting VS Code. These extensions can help create Spring projects, navigate beans, and work with framework configuration. They improve development ergonomics but do not run the application in production.
What is a JAR file?
A Java archive; Spring Boot executable JARs commonly include an embedded web server. A Spring Boot executable JAR can include application classes, dependencies, and an embedded servlet server. That allows starting the app with java -jar without a separate deployment step.
What is a WAR file?
A web application archive traditionally deployed to a separately configured server. WAR deployment is common when an organization already manages a servlet container. By contrast, an executable Boot JAR usually starts its own embedded server.
How do you start a Maven Spring Boot application?
Run mvn spring-boot:run or use the Maven wrapper. This runs the main Boot application from the Maven project, usually starting an embedded server. Use Ctrl+C to stop the process during local development.
What is Spring Boot's default web port?
8080. For example, the slides visit http://localhost:8080 after starting a controller. You can override the port using server.port in your application configuration.
What is pom.xml?
The Maven file for dependencies, plugins, and build configuration. You declare starters, JDBC drivers, and plugins here so Maven can resolve required libraries. Example: adding spring-boot-starter-data-jpa enables JPA-related dependencies.
What is the Maven Wrapper?
Project scripts such as mvnw that run Maven using the project's specified distribution. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What are application.properties and application.yml?
Files for application configuration, such as ports, database credentials, and logging. For example, set spring.datasource.url to the database JDBC URL, plus username and password. YAML groups nested options; properties uses dotted keys.
Where does static web content usually go?
src/main/resources/static. Think of a concrete example from a Spring Boot application and explain when you would use this feature, not just its definition. Describe the behavior that changes when the feature is present.
What are server-side templates for?
Rendering markup views on the server instead of just returning JSON. Think of a concrete example from a Spring Boot application and explain when you would use this feature, not just its definition. Describe the behavior that changes when the feature is present.
What does spring-boot-starter-web include?
Dependencies for REST and web development, including Spring MVC and a servlet server. The Web starter brings the components needed for HTTP handlers and typical REST applications. In the course example, @GetMapping on a @RestController exposes Hello World.
What does spring-boot-starter-data-jpa include?
Spring Data JPA integration, with Hibernate commonly acting as the JPA provider. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What does spring-boot-starter-test include?
Testing support such as JUnit, Mockito, and Spring Test. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What is the Spring Boot starter parent?
A Maven parent providing dependency versions and useful build defaults. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What is DevTools?
Development tools that help restart applications after code changes. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What is Spring Boot Actuator?
A project exposing operational endpoints, including health and metrics. For example, /actuator/health can help operators check whether an application is healthy. Expose only appropriate endpoints and secure sensitive ones.
What does /actuator/health report?
Application health status, often UP or DOWN. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
Why restrict Actuator endpoint exposure?
Operational details can expose sensitive system information. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
Where can logging levels be configured?
In application.properties or application.yml. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What does a Spring container do?
Creates, configures, injects, and manages bean lifecycles. Think of a concrete example from a Spring Boot application and explain when you would use this feature, not just its definition. Describe the behavior that changes when the feature is present.
What is a Spring bean?
An object managed by the Spring container. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What is constructor injection?
Passing dependencies through a constructor; preferred for required dependencies. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What is setter injection?
Supplying dependencies through setter methods after construction. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What is field injection?
Injecting dependencies directly into fields; generally less testable. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What is @Autowired?
An annotation used to request dependency injection from Spring. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What is @Component?
An annotation identifying a class as a Spring-managed component. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does component scanning do?
Discovers eligible component classes in configured packages. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @SpringBootApplication encompass?
Boot configuration, auto-configuration, and component scanning. Think of a concrete example from a Spring Boot application and explain when you would use this feature, not just its definition. Describe the behavior that changes when the feature is present.
What does @Qualifier do?
Selects a specific bean when multiple beans match the same type. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What does @Primary do?
Marks a preferred bean among multiple matching candidates. For example, a controller can receive a UserService through its constructor instead of creating it with new. This reduces coupling and lets tests supply a mock service.
What is default bean scope?
Singleton, meaning one bean instance per container bean definition. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What is prototype scope?
A new bean instance is created each time the container is asked for one. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @Lazy do?
Delays bean initialization until first needed. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @PostConstruct do?
Marks an initialization method run after dependency injection. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @PreDestroy do?
Marks a cleanup callback before a managed bean is destroyed. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
Why use @Configuration and @Bean?
To explicitly register beans, including types you cannot annotate yourself. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What is ORM?
Object-relational mapping between Java objects and relational database tables. Instead of manually reading JDBC ResultSet rows, a mapped Student object can represent a row of the student table. ORM maps properties and relationships to database structures.
What is Hibernate?
An ORM implementation that persists Java objects to relational databases. Hibernate translates entity operations into SQL and coordinates entity state within a Session or persistence context. JDBC still operates underneath, even when applications do not use JDBC directly.
What does JPA stand for?
Jakarta Persistence API, a specification for Java object persistence. The specification describes portable persistence concepts and interfaces, including EntityManager. Providers such as Hibernate and EclipseLink implement those contracts.
How is Hibernate related to JPA?
Hibernate implements the JPA specification. You code against standard JPA interfaces while Hibernate supplies the underlying behavior. That can reduce dependence on one persistence provider, though vendor-specific features still exist.
Why use Hibernate instead of plain JDBC?
It reduces manual SQL, result mapping, and persistence boilerplate. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
Which JDBC driver is used in the slides for PostgreSQL?
The PostgreSQL JDBC driver, org.postgresql:postgresql. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
Which properties commonly connect Spring to a database?
spring.datasource.url, spring.datasource.username, and spring.datasource.password. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What is EntityManager?
The JPA API for interacting with a persistence context and managing entities. Typical operations include persist to manage a new entity and find to locate one by primary key. It offers more direct control over persistence behavior than a standard JpaRepository.
What is JpaRepository?
A Spring Data abstraction offering CRUD, sorting, pagination, and queries. For example, interface StudentRepository extends JpaRepository
EntityManager vs JpaRepository?
EntityManager provides lower-level control; JpaRepository simplifies common CRUD work. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What is a persistence context?
The managed set of entity instances tracked by a JPA provider. The context tracks entity identity and changes. When a managed entity is changed in a transaction, Hibernate can detect those changes and write the updates during flush.
What is Hibernate Session?
Hibernate's API for interacting with persistent entities and the database. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What is JPQL?
A query language that uses entity names and properties rather than database table names. For example, SELECT s FROM Student s addresses the Student Java entity, not the students table. JPQL helps keep queries based on mapped domain classes.
What is HQL?
Hibernate's query language, similar to JPQL with Hibernate-specific extensions. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What is native SQL?
Database SQL that directly references tables and columns. For example, SELECT * FROM students uses actual table and column names. Native SQL can use database-specific features but reduces portability compared with JPQL.
What does SELECT s FROM Student s reference?
The Student entity class, not necessarily a table called Student. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What does @Entity mark?
A class representing a persistent JPA entity. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What does @Id mark?
An entity's primary-key attribute. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What does @GeneratedValue configure?
Automatic primary-key generation. In a Student application, an entity maps Java fields to database columns, while the persistence provider translates changes into SQL through JDBC. The ORM reduces repetitive data-access code but still requires correct mappings and transactions.
What does @Service mark?
A Spring component holding business logic. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @Repository mark?
A Spring component handling data access. Spring manages the relevant object within its application context; annotations and scanning determine which classes are registered. This keeps wiring and lifecycle responsibilities out of normal business code.
What does @RestController mark?
A controller whose request handlers typically return response bodies such as JSON. For example, an Angular client can send JSON to a Spring REST endpoint; the controller binds the request to a Java object, calls a service, then returns a response. Keep HTTP handling separate from business and persistence logic.
What is Jackson?
A library for converting Java objects to and from JSON. When a REST method returns a Java object, Jackson typically serializes it to JSON; when @RequestBody receives JSON, it deserializes it into a Java object.
What is serialization?
Converting a Java object into JSON or another transport format. For example, an Angular client can send JSON to a Spring REST endpoint; the controller binds the request to a Java object, calls a service, then returns a response. Keep HTTP handling separate from business and persistence logic.
What is deserialization?
Converting JSON into a Java object. For example, an Angular client can send JSON to a Spring REST endpoint; the controller binds the request to a Java object, calls a service, then returns a response. Keep HTTP handling separate from business and persistence logic.
What does @NotNull validate?
A value must not be null. For example, a registration endpoint can reject a blank email before persisting the record. Application-level validation provides useful client errors; database constraints provide another layer of protection.
What does @NotEmpty validate?
A string, collection, or array must not be null or empty. For example, a registration endpoint can reject a blank email before persisting the record. Application-level validation provides useful client errors; database constraints provide another layer of protection.
What does @NotBlank validate?
A string cannot be null, empty, or whitespace-only. For example, a registration endpoint can reject a blank email before persisting the record. Application-level validation provides useful client errors; database constraints provide another layer of protection.
What does @Valid trigger?
Bean Validation for an annotated argument or object. For example, @Valid @RequestBody StudentDto validates the DTO against constraints like @NotBlank before normal controller processing continues.
What does @Column(nullable=false) request?
A non-null database column constraint in generated schema mapping. For example, a registration endpoint can reject a blank email before persisting the record. Application-level validation provides useful client errors; database constraints provide another layer of protection.
What is a custom runtime exception for?
Representing an application-specific error such as a missing record. In a typical Spring Boot project, you select dependencies, configure environment-specific settings, and run the application with Maven or a packaged executable. Its defaults reduce setup work while still allowing customization.
What is @RestControllerAdvice?
Global REST controller advice, often used for exception handling. A request for a missing record should return a clear error body and an appropriate HTTP status, such as 404. Centralized exception handling avoids duplicating this logic in every controller.
What does @ExceptionHandler do?
Maps a particular exception type to a handler method. A request for a missing record should return a clear error body and an appropriate HTTP status, such as 404. Centralized exception handling avoids duplicating this logic in every controller.
Why return ResponseEntity?
To specify an HTTP status, headers, and response body. A controller can return ResponseEntity.status(404).body(error) when a resource is absent. This clearly communicates both the HTTP result and explanatory payload.
What does @Transactional do?
Declares a transaction boundary managed by Spring. In a transfer service, both account balance updates should be committed as one unit or rolled back together. Spring normally manages this around the transactional method.
What is REQUIRED propagation?
Joins an existing transaction or creates one if absent. For a banking transfer, both the debit and credit should succeed together or be rolled back together. Transaction configuration determines when work commits and how it interacts with concurrent requests.
What is REQUIRES_NEW propagation?
Suspends the current transaction and starts a separate one. For a banking transfer, both the debit and credit should succeed together or be rolled back together. Transaction configuration determines when work commits and how it interacts with concurrent requests.
What does transaction isolation control?
How concurrent transactions see each other's changes. For a banking transfer, both the debit and credit should succeed together or be rolled back together. Transaction configuration determines when work commits and how it interacts with concurrent requests.
What does @OneToOne map?
A relationship with one related entity on each side. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.
What does @OneToMany map?
One entity related to multiple others. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.
What does @ManyToOne map?
Multiple entities related to one parent entity. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.
What does @ManyToMany map?
Multiple entities on each side related to multiple on the other. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.
What does mappedBy identify?
The owning-side property of a bidirectional JPA relationship. For a Customer with accounts, the Customer.accounts collection may use mappedBy="customer" if Account.customer owns the join column. The inverse side does not define that foreign key.
Why create a join entity for many-to-many?
To store additional attributes about the relationship itself. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.
How do you declare a repository?
An interface extending JpaRepository
What can JpaRepository.findById return?
Optional
What are derived query methods?
Repository query methods parsed from names such as findByEmail. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What does countByStatus mean?
Count entity records where the status property matches. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What goes after By in a derived method name?
Entity property names and conditions that define the filter. Think of a concrete example from a Spring Boot application and explain when you would use this feature, not just its definition. Describe the behavior that changes when the feature is present.
When should you avoid derived query methods?
When query names become too long or relationship traversal becomes complex. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What does @Query do?
Defines a custom JPQL or native SQL repository query. The important distinction is whether you query mapped entity properties or physical database tables. Choose straightforward repository methods for simple lookups and explicit queries for more complex cases.
What does Pageable represent?
Pagination input, including page number, size, and often sorting. For example, PageRequest.of(0, 20) requests the first page of 20 records. This avoids returning an unbounded result set to the API caller.
What is a DTO?
A data transfer object that shapes request or response data. For example, AccountResponseDto can expose account number and balance without exposing internal entity fields. DTOs help keep persistence mappings separate from API contracts.
Why use DTOs?
To control API data and separate API contracts from persistence entities. For example, an Angular client can send JSON to a Spring REST endpoint; the controller binds the request to a Java object, calls a service, then returns a response. Keep HTTP handling separate from business and persistence logic.
How can derived queries navigate relationships?
With property paths, including underscores to disambiguate traversal. For instance, one customer may own multiple accounts, so you must model the owning side and any foreign-key column correctly. Fetch strategy matters because loading associations unnecessarily can hurt performance.