1 16 17 package org.springframework.beans.factory; 18 19 import org.springframework.beans.BeansException; 20 21 27 public class BeanNotOfRequiredTypeException extends BeansException { 28 29 30 private String beanName; 31 32 33 private Class requiredType; 34 35 36 private Class actualType; 37 38 39 46 public BeanNotOfRequiredTypeException(String beanName, Class requiredType, Class actualType) { 47 super("Bean named '" + beanName + "' must be of type [" + requiredType.getName() + 48 "], but was actually of type [" + actualType.getName() + "]"); 49 this.beanName = beanName; 50 this.requiredType = requiredType; 51 this.actualType = actualType; 52 } 53 54 55 58 public String getBeanName() { 59 return this.beanName; 60 } 61 62 65 public Class getRequiredType() { 66 return this.requiredType; 67 } 68 69 72 public Class getActualType() { 73 return this.actualType; 74 } 75 76 } 77 | Popular Tags |