没有找到Camel Bean Validator的组件

时间:2015-05-18 12:44:46

标签: java validation apache-camel bean-validation

我正在路上:Route(directRoute)[[From[direct-vm:getAddress]] -> [To[bean-v... because of Failed to resolve endpoint: bean-validator://validator?validationProviderResolver=myValidationProviderResolver due to: No component found with scheme: bean-validator

我添加了以下依赖项:

 <dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
</dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-bean-validator</artifactId>
      <version>2.12.0</version> 
    </dependency>

此外,我手动初始化HibernateValidationProviderResolver,因为我使用的是Camel版本2.12.0。我在camel-context.xml中添加以下行

<bean id="myValidationProviderResolver" class="com.beanvalidation.example.BeanValidation.HibernateValidationProviderResolver"/>

这就是调用我的验证器bean的方式:

<from uri="direct-vm:getAddress"/>
        <to uri="bean-validator:validator?validationProviderResolver=myValidationProviderResolver"/>

这是我的类HibernateValidationProviderResolver,我在我的课程中单独包含并在调用验证器时调用!

HibernateValidationProviderResolver implements ValidationProviderResolver {

      @Override
      public List getValidationProviders() {
        return singletonList(new HibernateValidator());
      }

    }

这是获取明确想法的pom文件..

<?xml version="1.0" encoding="UTF-8"?>
    <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">
        <parent>
            <groupId>com.example.parent.pom</groupId>
            <artifactId>build</artifactId>
            <version>0.1.2</version>
        </parent>

        <modelVersion>4.0.0</modelVersion>

        <groupId>com.example.bean-validation</groupId>
        <artifactId>getAddress</artifactId>
        <packaging>bundle</packaging>
        <version>0.0.8-SNAPSHOT</version>

        <name>Integration :: Service :: UK Address</name>

        <properties>
            <jackson.version>1.9.10</jackson.version>
        </properties>

        <dependencies>

            <!-- cxf -->
            <!-- regular http transport -->
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http</artifactId>
                <version>${cxf.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-core</artifactId>
                <version>${cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-bundle</artifactId>
                <version>${cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-api</artifactId>
                <version>${cxf.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework.osgi</groupId>
                <artifactId>spring-osgi-core</artifactId>
                <version>1.2.1</version>
                <scope>compile</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.0.7.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>3.0.7.RELEASE</version>
            </dependency>

            <!-- Core -->
            <dependency>
                <groupId>com.example.core</groupId>
                <artifactId>core</artifactId>
                <scope>provided</scope>
                <version>1.0.10</version>
            </dependency>

            <!-- cxf web container for unit testing x-->
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http-jetty</artifactId>
                <version>${cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-core</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-cxf</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-test</artifactId>
                <scope>test</scope>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-test-spring</artifactId>
                <scope>test</scope>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.osgi</groupId>
                <artifactId>spring-osgi-mock</artifactId>
                <version>1.2.1</version> 
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.5.0</version>
            </dependency>

            <dependency>
                <groupId>org.codehaus.jettison</groupId>
                <artifactId>jettison</artifactId>
                <version>1.3.5</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-jackson</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-jaxrs</artifactId>
                <version>1.9.10</version>
            </dependency>

            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>1.1.0.Final</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-bean-validator</artifactId>
                <version>${camel.version}</version> 
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>5.0.1.FINAL</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jboss.logging</groupId>
                        <artifactId>jboss.logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

        </dependencies>

        <build>
            <!-- defaultGoal>install</defaultGoal -->

            <plugins>
                <!-- to generate the MANIFEST-FILE of the bundle -->
                <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>${basedir}/target/generated-sources/jaxws</sourceRoot>
                                <wsdlOptions>
                                    <wsdlOption>
                                        <wsdl>${basedir}/src/main/resources/wsdl/out/neweb.wsdl</wsdl>
                                    </wsdlOption>

                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.4</version>
                    <extensions>true</extensions>
                    <configuration>

                        <instructions>  
                            <Bundle-SymbolicName>getAddress</Bundle-SymbolicName>

                            <Import-Package>                    
                                javax.jws,
                                javax.jws.soap,
                                javax.xml.bind,
                                javax.xml.bind.annotation,
                                javax.xml.bind.annotation.adapters,
                                javax.xml.datatype,
                                javax.xml.namespace,
                                javax.xml.ws,
                                javax.ws.rs,
                                javax.ws.rs.core,
                                javax.validation,
                                javax.validation.constraints,
                                javax.validation.metadata,
                                org.apache.camel,
                                org.apache.camel.component.http,
                                org.apache.camel.spring.spi,
                                org.apache.commons.httpclient,
                                org.apache.commons.httpclient.params,
                                org.apache.cxf.feature,
                                org.apache.cxf.jaxrs.provider.json,
                                org.apache.cxf.jaxrs.utils,
                                org.codehaus.jackson.jaxrs,
                                org.slf4j,
                                javax.validation.bootstrap,
                                org.hibernate.validator
                            </Import-Package>
                            <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
                        </instructions>
                    </configuration>
                </plugin>
            </plugins>

        </build>

    </project>

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

this Microsoft documentation中所述,camel-bean-validator不允许在Camel版本2.13之前设置validationProviderResolver