Spring Boot Coding Terms & Usage
@SpringBootApplication
Marks the main class of a Spring Boot app. It combines @Configuration, @EnableAutoConfiguration, and
@ComponentScan.
@RestController
Defines REST API endpoints. It's a combination of @Controller and @ResponseBody.
@GetMapping / @PostMapping / @PutMapping / @DeleteMapping
Maps HTTP GET, POST, PUT, DELETE methods to controller methods respectively.
@RequestBody
Binds the HTTP request body to a method parameter, commonly used in POST and PUT requests.
@PathVariable
Binds a method parameter to a URI template variable. Example: /user/{id} -> @PathVariable Long id.
@RequestParam
Used to extract query parameters from the URL. Example: ?page=1 -> @RequestParam int page.
@Entity
Marks a Java class as an entity to be managed by JPA. Represents a table in the database.
@Id / @GeneratedValue
@Id marks the primary key field. @GeneratedValue auto-generates the value.
JpaRepository
Spring Boot Coding Terms & Usage
Interface for generic CRUD operations. Example: UserRepository extends JpaRepository<User, Long>.
@Service
Marks a class as a service provider, where business logic is implemented.
@Autowired
Automatically injects dependencies in Spring-managed classes.
application.properties
Configuration file where database URLs, ports, and other properties are set.
Validation Annotations
Includes @NotNull, @Size, @Email, used to validate incoming request data.
@ControllerAdvice
Handles exceptions globally in the application. Used with @ExceptionHandler.
@Table / @Column
Customize the database table and column names.
Postman
A tool to test REST APIs by sending HTTP requests and viewing responses.