java - cvc-complex-type.2.4.c : The matching wildcard is strict, 但找不到元素 'jaxws:inInterceptors' 的声明

标签 java xml spring maven pom.xml

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

<jaxws:inInterceptors>

我尝试在线谷歌搜索,建议是将与依赖相关的 jawx 添加到我的 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>

最佳答案

在您的代码中,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

关于java - cvc-complex-type.2.4.c : The matching wildcard is strict, 但找不到元素 'jaxws:inInterceptors' 的声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39313020/

相关文章:

java - Spring MVC - 什么是 url 路径信息?

java - 如何从 Controller 更改 JSP 中元素的类?

java - 如何使用 dao、hibernate 检查同名项目是否存在

java - 用 root 根页面替换/设置 tomcat 欢迎页面

java - 如何更新/插入 XML 文件中现有节点的数据?

AngularJs watch angular.element

java - 以编程方式从远程 Maven 存储库下载工件

java - 等待 Angular 完成加载问题

html - 如何将溢出内容设置在下面而不是放在一行中

.net - 是否有一个类可以从 .NET 中的 XSD 架构生成示例 XML 文档