Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views4 pages

Library Management

The document outlines a Java Spring application for managing a library system. It includes a LibraryController class for adding and listing books, a Book entity class, and a LibraryService class that handles book storage and retrieval. The application uses annotations for configuration and dependency injection in Spring framework.

Uploaded by

gurudaddy599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Library Management

The document outlines a Java Spring application for managing a library system. It includes a LibraryController class for adding and listing books, a Book entity class, and a LibraryService class that handles book storage and retrieval. The application uses annotations for configuration and dependency injection in Spring framework.

Uploaded by

gurudaddy599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

) 31

library.listBooks
(); 30
29
28
are","Shakespeare","7658766"); "12345"); "Ironman", ("Avengers", Book library.
add
addBook("tales 26
..."); library. println("Library:Adding of 1ibrary.
books
the to System.out.
24
23
(LibraryController.
class); context.getBean LibraryController
library 22
21
20
class) AnnotationConfigApplication
(Interface.
; Context ApplicationContext
new context 19
18
main(string[]
args){ void static public 17
Interface 160
@ComponentScanclass public 15
14
@Configuration 13
12
org.springframework.context.ApplicationContext; import 40 11
10
Library.Management 3
LibraryService
java Bookjava D
DLibraryControllerjava Test. Spring. þackage 12
Interfecejavax Orderja ava B java Driver Bookjava
a ApplicationConfig
java
D
ApplicationConfig java DBookjava a Driver,java B Orderjava Interfacejava LibraryControllerjava x Bookjava B
LibraryServicejava
2
1þackage Spring.Test. Library.Management. Controller;
3

11
4° import org.springframework. beans. factory. annotation.Autowired;
12 @ControlLer
13 public class LibraryController {
14
15® DAutowired
16 private LibraryService libraryService;
17
18
190 public void addBook (String title, String author, String isbn) {
20 Book book = new Book(title, author, isbn);
21 libraryService. add Book (book) ;
22
23
240 public void listBooks ()
25 List<Book> books = libraryservice. listBooks();
26 System.out. println("Listing all books ,.");
27 for (int i- 0; i <books.size(); i++) {
28 System.out. println( (i + 1) + ". " + books.get (i));
29
30
31 }
32
DApplicationConfig java B
Bookjava a Driver,java BOrder,java a Interface java BLibraryController.java Bookjave
2
1package Spring.Test. Library.Management. Entity;
3 public class Book K
private String title;
private string author;
private String isbn;

public Book(String title, String author, String isbn) {


this.title title;
this.author author;
this.isbn isbn;
12 }
13
140 public string getTitle() {
15 return title;
16
17
18" public String getAuthor() {
19 return authorj
20
21
220 public String getIsbn(
23 return isbn
24
25
260 @Override
27 public String tostring() {
28 return title + " by "+ author + + isbn;
29
ysevCejava
1 þackage Spring. Test. Library.Management. Service;
2
3e import org.springframework. stereotype.Service;D
9
10 @Service
11 public class LibraryService {
12 private List<Book> books = new ArrayList<>();
13
140 public void addBook (Book book) {
15 books,add (book) ;
16 System. out. println(" Book added= " + book);
17
18
190 public List<Book> listBooks() {
20 return books;
21 }
22 }
23

You might also like