cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'jaxws:inInterceptors'

时间:2016-09-04 02:22:49

标签: java xml spring maven pom.xml

我在Java EE Luna中使用Maven,并在我进行Maven安装之前尝试修复beans.xml中的错误,以构建和测试我构建的Web服务。我的代码中有一个错误,上面写着“cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素'jaxws:inInterceptors'”的声明。我的beans.xml文件中包含错误的确切行:

<jaxws:inInterceptors>

我尝试在网上搜索谷歌,建议是将依赖相关的jawxs添加到我的pom.xml文件中,但它没有用,所以我想知道我的xml代码有什么问题..

这是我的beans.xml中的代码:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

        <import resource="classpath:META-INF/cxf/cxf.xml" />

        <!-- Spring's component scan for identifying beans to be managed by the container. -->
        <context:component-scan base-package="au.edu.unsw.soacourse.addressing"/>

        <jaxws:endpoint 
          id="GNAFAddressingService" 
          implementor="au.edu.unsw.soacourse.addressing.GNAFAddressingService" 
          address="/GNAFAddressingServiceImpl" />


          <jaxws:inInterceptors>
            <ref bean="GNAFAddressingServiceSOAPInterceptor" />
          </jaxws:inInterceptors>


        <bean id="GNAFAddressingServiceSOAPInterceptor" class="au.edu.unsw.soacourse.addressing.GNAFAddressingServiceSOAPInterceptor" />  

</beans>

这是我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>au.edu.unsw.soacourse</groupId>
    <artifactId>GNAFAddressingService</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Simple CXF Java-first SOAP project using Spring configuration</name>
    <description>Simple CXF Java-first SOAP project using Spring configuration</description>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-soap</artifactId>
            <version>${cxf.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-extension-providers</artifactId>
            <version>${cxf.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.8.11.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.0.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.0.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <!-- comp9322: adding a Maven plug-in from Apache CXF 
        for code generation (cxf-codegen-plugin). This plug-in
        runs WSDL2Java which is the actual tool that generates
        code from WSDL. This plug-in will run as a new goal 
        'generate-sources', which means you can also execute it 
        using 'mvn generate-sources' in the command line, or from 
        Run As -> Maven -> mvn generate-sources.
        -->
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.0.4</version>
                <executions>
                  <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                  <configuration>
                      <sourceRoot>src/main/java-generated</sourceRoot>
                      <wsdlOptions>
                          <wsdlOption>
                              <wsdl>${basedir}/src/main/resources/wsdl/GNAFAddressingService.wsdl</wsdl>
                          </wsdlOption>
                      </wsdlOptions>
                  </configuration>
                  <goals>
                      <goal>wsdl2java</goal>
                  </goals>
                  </execution>
                </executions>
            </plugin> 
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <!-- mvn clean install tomcat:run-war to deploy
                    Look for "Running war on http://xxx" and
                    "Setting the server's publish address to be /yyy"
                    in console output; WSDL browser address will be
                    concatenation of the two: http://xxx/yyy?wsdl
                    -->
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.0</version>
                    <executions>
                        <execution>
                            <id>start-tomcat</id>
                            <goals>
                                <goal>run-war</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <port>${test.server.port}</port>
                                <path>/webservice</path>
                                <fork>true</fork>
                                <useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <!-- comp9322: maven-compiler-plugin part 
                        referencing JDK 1.7 instead of default 1.6
                        -->
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <configuration>
                        <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
                        <wtpmanifest>true</wtpmanifest>
                        <wtpapplicationxml>true</wtpapplicationxml>
                        <wtpversion>2.0</wtpversion>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

1 个答案:

答案 0 :(得分:0)

在您的代码中xsi:schemaLocation =“之后有空格和换行。请尝试将其删除并将第一个值放在同一行。

更改

xsi:schemaLocation="
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd

对此:

xsi:schemaLocation="http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd