不能在eclipse中从wsdl生成Java类

时间:2016-09-28 06:13:33

标签: java eclipse web-services maven wsdl

Pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.ServiceTest</groupId>
      <artifactId>SpericalClient</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>SpericalClient</name>
      <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <basedir>
            E:\Radhika\Eclipse_Projects\SpericalClient
        </basedir>    
      </properties>


      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

     <build>
         <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2.maven2</groupId>
                        <artifactId>maven-jaxb2-plugin</artifactId>
                        <version>0.13.1</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>com.ServiceTest.SpericalClient</generatePackage>
                            <schemas>
                                <schema>
                                    <url>https://50.204.173.177:443/SphericallService</url>
                                </schema>
                            </schemas>
                        <configuration>
                            <packageName>com.ServiceTest.SpericalClient</packageName>
                            <wsdl>true</wsdl>
                            <xmlschema>false</xmlschema>
                            <schemaFiles>service.wsdl</schemaFiles>
                        </configuration>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>jaxws-maven-plugin</artifactId>
                        <version>1.12</version>
                        <configuration>
                            <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
                            <packageName>com.raps.code.generate.ws</packageName>
                            <keep>true</keep>
                            <sourceDestDir>${basedir}/target/generated/src/main/java</sourceDestDir>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>wsimport</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
          </pluginManagement>
    </build>

    </project>

当我尝试从maven生成类生成类到低于输出

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SpericalClient 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.121 s
[INFO] Finished at: 2016-09-28T11:22:07+05:30
[INFO] Final Memory: 5M/75M
[INFO] ------------------------------------------------------------------------

文件夹结构: wsdl文件位于src-&gt; main-&gt; resources-&gt; wsdl文件夹中 xsd文件位于src-&gt; main-&gt; resources-&gt;架构文件夹

包名也是com.ServiceTest.SpericalClient

1 个答案:

答案 0 :(得分:0)

您的插件永远不会被执行,因为它只在pluginManagement中声明

看看这里:https://stackoverflow.com/a/10483284/1811730

您可以添加

<plugins>
     <plugin>
         <groupId>org.jvnet.jaxb2.maven2</groupId>
         <artifactId>maven-jaxb2-plugin</artifactId>
     </plugin>
 </plugins>

到像这样的构建标记

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ServiceTest</groupId>
  <artifactId>SpericalClient</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>SpericalClient</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <basedir>
        E:\Radhika\Eclipse_Projects\SpericalClient
    </basedir>    
  </properties>


  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

 <build>
     <plugins>
         <plugin>
             <groupId>org.jvnet.jaxb2.maven2</groupId>
             <artifactId>maven-jaxb2-plugin</artifactId>
         </plugin>
     </plugins>

     <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <version>0.13.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <schemaLanguage>WSDL</schemaLanguage>
                        <generatePackage>com.ServiceTest.SpericalClient</generatePackage>
                        <schemas>
                            <schema>
                                <url>https://50.204.173.177:443/SphericallService</url>
                            </schema>
                        </schemas>
                    <configuration>
                        <packageName>com.ServiceTest.SpericalClient</packageName>
                        <wsdl>true</wsdl>
                        <xmlschema>false</xmlschema>
                        <schemaFiles>service.wsdl</schemaFiles>
                    </configuration>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxws-maven-plugin</artifactId>
                    <version>1.12</version>
                    <configuration>
                        <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
                        <packageName>com.raps.code.generate.ws</packageName>
                        <keep>true</keep>
                        <sourceDestDir>${basedir}/target/generated/src/main/java</sourceDestDir>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
      </pluginManagement>
</build>

</project>