1/255
Looks like no tags are added yet.
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. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
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. For example, use mvn spring-boot:run during development; an executable JAR can run with java -jar.
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.
What are server-side templates for?
Rendering markup views on the server instead of just returning JSON. For example, GET /students/1 can return a Student DTO serialized as JSON.
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. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
What does spring-boot-starter-test include?
Testing support such as JUnit, Mockito, and Spring Test. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
What is the Spring Boot starter parent?
A Maven parent providing dependency versions and useful build defaults. For example, use mvn spring-boot:run during development; an executable JAR can run with java -jar.
What is DevTools?
Development tools that help restart applications after code changes. For example, GET /students/1 can return a Student DTO serialized as JSON.
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. For example, /actuator/health checks application health; expose only appropriate management endpoints.
Why restrict Actuator endpoint exposure?
Operational details can expose sensitive system information. For example, /actuator/health checks application health; expose only appropriate management endpoints.
Where can logging levels be configured?
In application.properties or application.yml.
What does a Spring container do?
Creates, configures, injects, and manages bean lifecycles. This affects when Spring creates, reuses, initializes, or cleans up a bean.
What is a Spring bean?
An object managed by the Spring container. For example, a UserController can receive a UserService bean through constructor injection.
What is constructor injection?
Passing dependencies through a constructor; preferred for required dependencies.
What is setter injection?
Supplying dependencies through setter methods after construction.
What is field injection?
Injecting dependencies directly into fields; generally less testable.
What is @Autowired?
An annotation used to request dependency injection from Spring. For example, a UserController can receive a UserService bean through constructor injection.
What is @Component?
An annotation identifying a class as a Spring-managed component. For example, a UserController can receive a UserService bean through constructor injection.
What does component scanning do?
Discovers eligible component classes in configured packages.
What does @SpringBootApplication encompass?
Boot configuration, auto-configuration, and component scanning. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
What does @Qualifier do?
Selects a specific bean when multiple beans match the same type. Use these when multiple beans implement the same interface and Spring needs help choosing one.
What does @Primary do?
Marks a preferred bean among multiple matching candidates. Use these when multiple beans implement the same interface and Spring needs help choosing one.
What is default bean scope?
Singleton, meaning one bean instance per container bean definition. This affects when Spring creates, reuses, initializes, or cleans up a bean.
What is prototype scope?
A new bean instance is created each time the container is asked for one. This affects when Spring creates, reuses, initializes, or cleans up a bean.
What does @Lazy do?
Delays bean initialization until first needed. This affects when Spring creates, reuses, initializes, or cleans up a bean.
What does @PostConstruct do?
Marks an initialization method run after dependency injection. This affects when Spring creates, reuses, initializes, or cleans up a bean.
What does @PreDestroy do?
Marks a cleanup callback before a managed bean is destroyed. This affects when Spring creates, reuses, initializes, or cleans up a bean.
Why use @Configuration and @Bean?
To explicitly register beans, including types you cannot annotate yourself. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
Which JDBC driver is used in the slides for PostgreSQL?
The PostgreSQL JDBC driver, org.postgresql:postgresql. The JDBC URL, username, password, and database driver let Spring Boot configure database connectivity.
Which properties commonly connect Spring to a database?
spring.datasource.url, spring.datasource.username, and spring.datasource.password. The JDBC URL, username, password, and database driver let Spring Boot configure database connectivity.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @Entity mark?
A class representing a persistent JPA entity. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @Id mark?
An entity's primary-key attribute. Use these when multiple beans implement the same interface and Spring needs help choosing one.
What does @GeneratedValue configure?
Automatic primary-key generation. Use these when multiple beans implement the same interface and Spring needs help choosing one.
What does @Service mark?
A Spring component holding business logic. For example, a UserController can receive a UserService bean through constructor injection.
What does @Repository mark?
A Spring component handling data access. For example, a UserController can receive a UserService bean through constructor injection.
What does @RestController mark?
A controller whose request handlers typically return response bodies such as JSON. For example, GET /students/1 can return a Student DTO serialized as JSON.
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, GET /students/1 can return a Student DTO serialized as JSON.
What is deserialization?
Converting JSON into a Java object. For example, GET /students/1 can return a Student DTO serialized as JSON.
What does @NotNull validate?
A value must not be null. For example, request validation rejects a blank email before attempting to save the entity.
What does @NotEmpty validate?
A string, collection, or array must not be null or empty.
What does @NotBlank validate?
A string cannot be null, empty, or whitespace-only. For example, request validation rejects a blank email before attempting to save the entity.
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 Student entity can map to a database table while a repository retrieves matching records.
What is a custom runtime exception for?
Representing an application-specific error such as a missing record. For example, a missing student record can become a consistent HTTP 404 JSON response.
What is @RestControllerAdvice?
Global REST controller advice, often used for exception handling. For example, a missing student record can become a consistent HTTP 404 JSON response.
What does @ExceptionHandler do?
Maps a particular exception type to a handler method. For example, a missing student record can become a consistent HTTP 404 JSON response.
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 bank transfer, debit and credit operations should commit together or roll back together.
What is REQUIRES_NEW propagation?
Suspends the current transaction and starts a separate one. For a bank transfer, debit and credit operations should commit together or roll back together.
What does transaction isolation control?
How concurrent transactions see each other's changes. For a bank transfer, debit and credit operations should commit together or roll back together.
What does @OneToOne map?
A relationship with one related entity on each side. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @OneToMany map?
One entity related to multiple others. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @ManyToOne map?
Multiple entities related to one parent entity. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @ManyToMany map?
Multiple entities on each side related to multiple on the other.
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 example, a Student entity can map to a database table while a repository retrieves matching records.
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. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does countByStatus mean?
Count entity records where the status property matches. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
What goes after By in a derived method name?
Entity property names and conditions that define the filter. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.
When should you avoid derived query methods?
When query names become too long or relationship traversal becomes complex. For example, a Student entity can map to a database table while a repository retrieves matching records.
What does @Query do?
Defines a custom JPQL or native SQL repository query. For example, a Student entity can map to a database table while a repository retrieves matching records.
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, a Student entity can map to a database table while a repository retrieves matching records.
How can derived queries navigate relationships?
With property paths, including underscores to disambiguate traversal. For example, adding spring-boot-starter-web supplies common dependencies for HTTP endpoints.