FSD NM
FSD NM
DEPARTMENT OF
INFORMATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
A PROJECT REPORT
Submitted by
--------------------------- ---------------------------
BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
BHARATHIDASAN ENGINEERING COLLEGE
(Approved by AICTE and Affiliated with Anna University, Chennai – 600 025)
BONAFIDE CERTIFICATE
Certified that candidates were examined in the viva – voce examination held at
Bharathidasan Engineering College, Nattrampalli on ________________________.
SIGNATURE SIGNATURE
SIGNATURE
We wish our heartfelt thanks to our respected Management for the Blessings and
constant support over our project period.
We wish to express our sincere thanks to our respected Principal Dr. G. BASKAR
M.E., Ph.D., FIE. For all the blessing and help provided during the period of
project work.
We are in deep gratitude to our department faculty who always been supporting us
through thick and thin respected HEAD OF THE DEPARTMENT Mrs. R.
VASANTHI, M.E ,PhD., for the continuous support for the project.
We wish to express our sincere thanks to our respected PROJECT GUIDE Mr.
S.THAMILVANAN, M.E., Assistant Professor for her constant help and creative
ideas to Complete this project.
We would like to extend warmest thanks to all our Department Faculty Members
and supporting faculties for helping this project's successful completion
unflinching support and encouragement from the member of our Family and
Friends. We must thank them all from our depth and heart.
FULL STACK DEVELOPMENT
WITH JAVA
1 Introduction 1
4 Spring REST 15
5 Conclusion 17
6 Certificates 20
INTRODUCTION:
Full stack developers possess the skills and knowledge to work across the entire
technology stack, enabling seamless user experiences and developing robust
backends.
The front end is the face of a web application, the part that users interact with
directly. Full stack web developers possess a deep understanding of front-end
technologies, including HTML, CSS, and JavaScript. They leverage these
foundational languages to structure, style, and enhance the visual appeal of web
pages.
Full stack developers are proficient in server-side languages such as Python, Ruby,
PHP, and JavaScript, allowing them to build robust and scalable back-end systems.
Back-end developers play a crucial role in designing and implementing the
application's core functionality, handling data management, and ensuring smooth
integration with databases like MySQL, MongoDB, or PostgreSQL.
Back-end development involves more than just writing code. Full stack developers
have a keen understanding of server architecture and API development. They design
and implement RESTful APIs that enable seamless communication between the
front-end and back-end components of the application.
SPRING 5 BASIC WITH SPRING BOOT:
1. Spring Boot Basics:
Use Spring Initializr to create a new Spring Boot project with dependencies
(https://start.spring.io).
Service: Business logic goes into service classes annotated with @Service.
@RestController
@RequestMapping("/api")
@GetMapping("/hello")
1. Add Dependencies:
In your pom.xml (for Maven) or build.gradle (for Gradle), add the spring-
boot-starter-data-jpa dependency:
This includes JPA and an embedded H2 database, useful for quick testing.
Create a Java class and annotate it with @Entity to map it to a database table:
import javax.persistence.*;
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private Double price;
import org.springframework.data.jpa.repository.JpaRepository;
Spring Data JPA will provide basic CRUD operations out of the box.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProductService {
@Autowired
private ProductRepository productRepository;
6. Controller Layer:
Create a REST controller to expose endpoints for interacting with your data:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/products")
public class ProductController {
@Autowired
private ProductService productService;
@GetMapping
public List<Product> getAllProducts() {
return productService.findAllProducts();
}
@PostMapping
public Product createProduct(@RequestBody Product product) {
return productService.saveProduct(product);
}
}
The API endpoints will be accessible, and you can interact with the database
through CRUD operations.
Spring Data JPA allows for query methods using a naming convention:
SPRING REST:
1.Setting Up Dependencies:
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/products")
public class ProductController {
@GetMapping("/{id}")
public Product getProductById(@PathVariable Long id) {
// Fetch product from service layer (mock example here)
return new Product(id, "Sample Product", 29.99);
}
@PostMapping
public Product createProduct(@RequestBody Product product) {
// Save product to the database (mock example here)
return product;
}
@PutMapping("/{id}")
public Product updateProduct(@PathVariable Long id, @RequestBody
Product product) {
// Update product in the database (mock example here)
product.setId(id);
return product;
}
@DeleteMapping("/{id}")
public String deleteProduct(@PathVariable Long id) {
// Delete product from the database (mock example here)
return "Product with ID " + id + " deleted successfully";
}
}
import org.springframework.stereotype.Service;
@Service
public class ProductService {
public Product getProductById(Long id) {
// Simulate fetching product from a data source
return new Product(id, "Sample Product", 29.99);
}
5. Exception Handling
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public String handleNotFoundException(ResourceNotFoundException ex)
{
return ex.getMessage();
}}
6. Using ResponseEntity
Example:
@GetMapping("/{id}")
public ResponseEntity<Product> getProductById(@PathVariable Long id) {
Product product = productService.getProductById(id);
return product != null
? ResponseEntity.ok(product)
: ResponseEntity.notFound().build();
}
Run the Spring Boot application, then test endpoints using Postman or a tool
like curl:
8. JSON/XML Serialization
Spring Boot automatically converts Java objects to JSON for the response.
You can customize the serialization with Jackson annotations like
@JsonIgnore or @JsonProperty.
9. Advanced Features
Pagination and Sorting: Use Spring Data JPA with Pageable and Sort to
handle paginated and sorted responses.
HATEOAS: For Hypermedia support, you can add links to resources, helping
clients navigate the API more effectively.
Versioning: For larger APIs, you may want to version your endpoints (e.g.,
/api/v1/products).
This setup gives you a basic REST API in Spring Boot, ready for
enhancements and scaling.
CONCLUSION:
Spring 5 with Spring Boot simplifies application setup and configuration, offering
embedded servers, auto-configuration, and a rich set of dependencies that speed up
development while maintaining best practices. This approach is particularly useful
for creating microservices or standalone applications.Spring Data JPA with Spring
Boot abstracts much of the complexity of database interaction.It provides an
intuitive way to manage data using repositories, minimizing boilerplate code for
CRUD operations.Its integration with various databases, automatic query creation,
and support for custom queries make data handling efficient and developer-
friendly.Spring REST leverages Spring MVC to build RESTful APIs, enabling easy
exposure of business logic to clients. With Spring’s annotations (@RestController,
@RequestMapping, etc.), creating clean, readable, and maintainable APIs becomes
straightforward. Spring REST supports essential features such as request/response
handling, exception management, and integration with JSON and XML, making it a
go-to choice for backend API development.
CERTIFICATES: