java "Class file contains wrong class"错误

标签 java web-services classpath webservice-client wsimport

我正在尝试创建一个控制台应用程序来测试我的网络服务。 我在 http://localhost:8080/WS/myWS 成功部署了一个网络服务 我用 wsimport 制作了代理类:

wsimport -d bin -s src http://localhost:8080/WS/myWS?wsdl

现在我的网络服务类位于 bin/mywebservice/中,我正在尝试使用 classpath = ./编译我的客户端类

这是我的类(class)的源代码:

import bin.mywebservice.myClass_Service;
public class TesterApp{
    public static void main (String args[])
    {    
        myClass_Service service = new myClass_Service(); 
    }
}

我有错误:

TesterApp.java:1: error: cannot access myClass_Service
import bin.mywebservice_Service.myClass;
                               ^
  bad class file: .\bin\mywebservice\myClass_Service.class
    class file contains wrong class: mywebservice.myClass_Service
    Please remove or make sure it appears in the correct subdirectory of the classpath.

请帮忙,myClass_Service 出了什么问题? 我发誓,myClass_Service.class 存在于 .\bin\mywebservice\

最佳答案

您在 import 声明中错误地包含了 bin

而是将 bin 放在类路径中并更正 import

除非(命名不当的)myClass_Service.java 文件是 package bin.mywebservice(根据错误消息,它不是),你是试图在错误的地方纠正问题。

关于java "Class file contains wrong class"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8377239/

相关文章:

java - Firestore-检查用户名是否已存在

java - 无法组装交易,错误提案响应未成功,错误代码 500

java - SOAP 使用适配器休息服务

android - 在 Android 客户端/服务器应用程序中实现 Google 登录

java - 项目不在 Eclipse 构建路径中

java - 在 ant buildfile 中添加带有 libs 的文件夹

java - 如何在java运行时创建数组?

java - 在哪里设置 EJB3 客户端的 Web 服务主机名

执行JAR时java.lang.ClassNotFoundException : com. mysql.jdbc.Driver

java - 无法在 Spring REST Web 服务中成功使用验证