相关疑难解决方法(0)

如何使wsimport生成构造函数?

wsimport生成没有参数化构造函数的源代码.因此,如果bean具有许多属性,则需要手动调用所有setter:

Person person = new Person();
person.setName("Alex");

Address address = new Address();
address.setCity("Rome");

person.setAddress(address);
Run Code Online (Sandbox Code Playgroud)

只需编写如下代码,它就更具可读性和便捷性:

Person person = new Person("Alex", new Address("Rome"))
Run Code Online (Sandbox Code Playgroud)

那么,有没有办法wsimport做这个工作?(我正在使用maven wsimport插件)

java web-services wsimport maven

9
推荐指数
2
解决办法
4974
查看次数

如何在jaxws中使用wsimport生成equals()和hashcode()方法

我使用wsimport的WSDL生成的类没有equals()hashcode()方法.如何自定义和生成客户端类以获取equals()hashcode()方法.

我不确定使用JAXB来实现这一点.

在Axis2.0生成的存根中生成了这些方法,但不确定为什么JAXWS中没有这样的基本功能!

jax-ws jaxb

6
推荐指数
1
解决办法
8636
查看次数

如何使用jaxb2生成toString方法?

我想从我的 wsdl 中重载 toString 方法。

在我的 pom.xml 中

  1. 我在依赖项中添加了它:

    <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb2-basics-runtime</artifactId>
        <version>1.11.1</version>
    </dependency>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 我在 build/plugins 中添加了这个插件

块引用

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.7.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${project.build.directory}/wsdl/META-INF/wsdl/</schemaDirectory>
                <schemaIncludes>
                    <include>FrameworkGedServiceMetier.wsdl</include>
                </schemaIncludes>
                <args>
                    <arg>-XtoString</arg>
                    <arg>-Xequals</arg>
                    <arg>-XhashCode</arg>
                    <arg>-Xcopyable</arg>
                </args>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>1.11.1</version>
                    </plugin>
                </plugins>
            </configuration>
        </plugin> 
Run Code Online (Sandbox Code Playgroud)

我构建maven 成功,但我的类中没有我的方法toString。

为了激励我,我使用这个文档

java jaxb tostring pom.xml maven

6
推荐指数
1
解决办法
4341
查看次数

标签 统计

java ×2

jaxb ×2

maven ×2

jax-ws ×1

pom.xml ×1

tostring ×1

web-services ×1

wsimport ×1