Spring Task

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

SPRING TASK

WRITE A PROGRAM TO ACCEPT A


NUMBER AND CHECK IF NUMBER IS
GREATER THAN 80 --- “EXCELLENT”
60-80 ---”Very Good”
40-60 ---- ”Good”
Below 40 --- “Average”
PROJECT CREATION
1. Create a new java application
2. Right –click on the ‘libraries’ folder and select ‘Add
JAR/Folder’ option and add the necessary spring
dependencies .
POJO CLASS
XML FILE
1. Right click on Source Packages and
go to New -> Other
2. Search xml document and click next
3. Specify the name of the document
4. Choose ‘Well Formed Document’ and
click finish.
5. Paste the schemas given in notes
6. Create a bean inside the
<beans></beans>
7. Specify the id and class of bean.
MAIN CLASS(SPRINGTASK)
1. Inside main() method , create a reference of ApplicationContext and instantiate it with the
object of ClassPathXmlApplicationContext class and pass the name of the xml in the
constructor like “example.xml”.
2. Create a reference of the POJO class and instantiate it with getBean() method of
ClassPathXmlApplicationContext and pass the id of the bean inside getBean() in “” and
typecast it with the POJO class.
3. Create an object of Scanner class to take input from command line and store it in an int
variable and pass the variable inside the setter method of the POJO class i.e. GreaterValue
4. Now create a static method checkNumber(GreaterValue num) and pass the object created in
step 3 to the method while calling it . View the notes…
OUTPUT

You might also like