D.Tech Academic
Deep Singh
Pages
Core Java
Web App
Spring
Hibernate
Kotlin
Android
Python
Flutter
Spring Boot
Spring Inheritance Example
Spring Inheritance Example
Car.java
package com.deepsingh44.model; public class Car { private String name; private float price; public String getName() { return name; } public void setName(String name) { this.name = name; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } }
MyCar.java
package com.deepsingh44.model; public class MyCar { private String name; private float price; private String avg; public String getName() { return name; } public void setName(String name) { this.name = name; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public String getAvg() { return avg; } public void setAvg(String avg) { this.avg = avg; } }
Test.java
package com.deepsingh44.model; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("spring_config.xml"); Object o = ac.getBean("mycar"); MyCar car = (MyCar) o; System.out.println(car.getName()); System.out.println(car.getPrice()); System.out.println(car.getAvg()); } }
spring_config.xml
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment