[英]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.