使用Web服务时如何配置pom.xml

时间:2019-04-18 19:55:45

标签: java maven soap cxf

我开发了一个Maven应用程序,当我从Netbeans运行它时,它工作正常,但是当我尝试使用jar文件时,它会产生以下错误:

  

org.apache.cxf.service.factory.ServiceConstructionException:无法为null解析绑定。”

我认为我的pom.xml文件配置不正确。

<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.18.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.1</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.1.0.jre8</version>           
        <scope>compile</scope>
    </dependency>


    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>3.0.0-M1</version>
        <type>maven-plugin</type>
    </dependency>

</dependencies>
<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <outputDirectory>MyDir</outputDirectory>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib</classpathPrefix>
                        <mainClass>com.mycompany.serviciowebdinardap.NewMain</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin> 

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
                <outputDirectory>Mydir_source</outputDirectory>
                <finalName>servicioWebDinardap</finalName>
                <attach>false</attach>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>3.0.0-M1</version>
        </plugin>


        <plugin>

            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.6.1</version>

            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <wsdlOptions>
                            <wsdlOption>
                                <bareMethods/>
                                <wsdl>${basedir}/src/main/resources/wsdl/DINARDAPService.wsdl</wsdl>
                                <packagenames>
                                    <packagename>com.mycompany.serviciowebdinardap</packagename>
                                </packagenames>
                            </wsdlOption>
                        </wsdlOptions>

                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.mycompany.serviciowebdinardap.NewMain</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> 
                    <phase>package</phase> 
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

检查类路径上是否存在if string1 eq 'apples' load('.apples') if string2 eq 'oranges' load('.apples') 。如果不是,请将其包括到cxf-rt-bindings-soap

pom.xml