Generate java source code according to webservice address

1. Create a new maven project
2. Add the following configuration to the pom.xml file:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
   <dependency>
       <groupId>junit</groupId>
        <artifactId>junit</artifactId>
         <version>4.12</version>
    </dependency>
        ....
</dependencies>
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.1.11</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!--源码生成地址-->
                            <sourceRoot>${project.build.sourceDirectory}</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>http://xxx/services/userAPI?wsdl</wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
</build>

3. Select Maven Project, click Execute Maven Goal, enter generate-sources, click Execute

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325881570&siteId=291194637