简体   繁体   English

如何修复此错误“XYZ 没有无参数构造函数”

[英]How do I fix this error "XYZ does not have a no-arg constructor"

I am trying to write a web service that listens for SPML requests.我正在尝试编写一个侦听 SPML 请求的 Web 服务。 I am using the spml version 2 toolkit.我正在使用 spml 版本 2 工具包。

I am using Jdeveloper to create this web serivce.我正在使用 Jdeveloper 创建此 Web 服务。

I create a method like this: public Response execute(Request req)我创建了一个这样的方法: public Response execute(Request req)

When I try and create a web service with jdeveloper...I get the following error:当我尝试使用 jdeveloper 创建 Web 服务时...我收到以下错误:

ExecutionMode does not have a no-arg constructor.

Does anybody know how to fix this..??有谁知道如何解决这个问题..?? An example of this would be greatly appreciated.这方面的一个例子将不胜感激。

Thanks, Brian谢谢,布莱恩

You need to add a default (no-arg) constructor to the ExecutionMode class.您需要向 ExecutionMode 类添加默认(无参数)构造函数。

public class ExecutionMode {
     public ExecutionMode() {
          // initialization code here
     }

     // other class code    

}

Presumably you have a class called ExecutionMode?大概您有一个名为 ExecutionMode 的类? The compiler is looking for a no argument constructor, ie.编译器正在寻找一个无参数构造函数,即。 a constructor that takes no arguments:一个不带参数的构造函数:

class ExecutionMode{
    ....
    public ExecutionMode(){...}
    ....
}

If you define a parameterized contructor then you should also define a default constructor if you use one because java wont provide default constructor if you define parameterized constructor.So you should define如果你定义了一个参数化的构造函数那么你也应该定义一个默认的构造函数如果你使用一个因为如果你定义参数化的构造函数java不会提供默认的构造函数。所以你应该定义

public ExecutionMode()
{

   //defination

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 JAXB 与 AutoValue 一起使用时,Marsheling 错误“没有无参数的默认构造函数” - Marsheling error "does not have a no-arg default constructor" when using JAXB with AutoValue 如果父级没有no-arg构造函数,则出现序列化问题 - Serialization issue if the parent does not have a no-arg constructor 什么可能导致“JAXBElement没有no-arg默认构造函数”? - What might cause “JAXBElement Does not have a no-arg default constructor”? 使用Jaxb和cxf,枚举“没有no-arg默认构造函数” - Enum “does not have a no-arg default constructor” with Jaxb and cxf 如何反序列化没有无参数构造函数的 com.auth0.jwk.Jwk? - How to deserialize com.auth0.jwk.Jwk that does not have no-arg constructor? Java类如何没有no-arg构造函数? - How can a Java class have no no-arg constructor? init 方法在 Spring 中工作是否需要无参数构造函数(忽略默认构造函数,因为我有一些参数构造函数)? - Is no-arg constructor(ignore default constructor as I have some arguments constructor) necessary for init method to work in Spring? IIOException如何没有no-arg构造函数? - How IIOException has no no-arg constructor? Hibernate和no-arg构造函数 - Hibernate and no-arg constructor 无法绑定到Web服务:java.lang.StackTraceElement没有无参数的默认构造函数 - Cannot bind to webservice: java.lang.StackTraceElement does not have a no-arg default constructor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM