0

I've got a problem with this program

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cdmiService': Cannot resolve reference to bean 'badRequestException' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'badRequestException' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.snia.cdmiserver.exception.BadRequestException]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.snia.cdmiserver.exception.BadRequestException.<init>()

and my xml is as follows:

 <bean id="badRequestException"     class="org.snia.cdmiserver.exception.BadRequestException"/>

The BadRequestException.java is as follows:

public class BadRequestException extends RuntimeException {
public BadRequestException(String message) {
    super(message);
}

public BadRequestException(String message, Throwable cause) {
    super(message, cause);
}

public BadRequestException(Throwable cause) {
    super(cause);
}

How could I solve this problem?add a default construtor or edit the xml file?

4

1 回答 1

0

我该如何解决这个问题?添加默认构造器或编辑 xml 文件?

你可以用任何一种方式解决它。

  1. 添加默认构造函数:

        public BadRequestException() {
           super();
        }
    
  2. 编辑xml文件

    <bean id="badRequestException"     class="org.snia.cdmiserver.exception.BadRequestException">
         <constructor-arg type="java.lang.String"><value>Message you want</value></constructor-arg>
    </bean >
    
于 2013-05-28T11:07:32.973 回答