Camel Bean Validator 未找到任何组件
No component found with Camel Bean Validator
我正在进入路线: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 版。我在我的骆驼中添加以下行-context.xml
<bean id="myValidationProviderResolver" class="com.beanvalidation.example.BeanValidation.HibernateValidationProviderResolver"/>
这就是我的验证器 bean 被调用的方式:
<from uri="direct-vm:getAddress"/>
<to uri="bean-validator:validator?validationProviderResolver=myValidationProviderResolver"/>
这是我的 class HibernateValidationProviderResolver,我将其单独包含在我的 class 中,并在调用验证器时调用!
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>
有人能帮忙吗?
camel-bean-validator
在 Camel 2.13 版本之前不允许设置 validationProviderResolver
,如 documentation.
中所述
我正在进入路线: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 版。我在我的骆驼中添加以下行-context.xml
<bean id="myValidationProviderResolver" class="com.beanvalidation.example.BeanValidation.HibernateValidationProviderResolver"/>
这就是我的验证器 bean 被调用的方式:
<from uri="direct-vm:getAddress"/>
<to uri="bean-validator:validator?validationProviderResolver=myValidationProviderResolver"/>
这是我的 class HibernateValidationProviderResolver,我将其单独包含在我的 class 中,并在调用验证器时调用!
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>
有人能帮忙吗?
camel-bean-validator
在 Camel 2.13 版本之前不允许设置 validationProviderResolver
,如 documentation.