插件名称:cxf-codegen-plugin
在pom.xml插件配置中添加
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<!-- 代码生成存放路径-->
<sourceRoot>src/main/java</sourceRoot>
<encoding>UTF-8</encoding>
<wsdlOptions>
<wsdlOption>
<!-- 以下两种方式都可行-->
<!-- <wsdl>http://localhost:9999/services/Hello?wsdl</wsdl>-->
<wsdl>${basedir}/src/main/resources/wsdl/HelloWeServiceImpl.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
- maven构建:mvn clean install 后将在sourceRoot配置的路径下生成客户端代码
- 测试并调用
HelloWeService helloWeService = new HelloWeServiceImplService().getHelloWeServiceImplPort();
System.out.println(helloWeService.sayHello("webServiceDemo"));
- SpringBoot 中直接注入接口类调用方法即可