Java 驼峰招摇过市多柱法投掷错误

Java 驼峰招摇过市多柱法投掷错误,java,tomcat,apache-camel,swagger,http-method,Java,Tomcat,Apache Camel,Swagger,Http Method,我正在尝试使用驼峰的招摇组件制作一个样本 下面是我的camel-context.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:camel="http://camel.apache.org/sch

我正在尝试使用驼峰的招摇组件制作一个样本

下面是我的camel-context.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:camel="http://camel.apache.org/schema/spring"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://camel.apache.org/schema/spring 
         http://camel.apache.org/schema/spring/camel-spring.xsd">

    <!-- a bean for user services -->
    <bean id="StudentService"
        class="temp.org.impl.StudentService" />

    <camelContext id="mycamel" xmlns="http://camel.apache.org/schema/spring">

        <!-- configure rest to use the camel-servlet component, and use json binding 
            mode -->
        <!-- and tell to output json in pretty print mode -->
        <restConfiguration component="servlet" bindingMode="json"
            contextPath="school/bo" port="8080">
            <dataFormatProperty key="prettyPrint" value="true" />
        </restConfiguration>


        <!-- defines the rest services using the context-path /user -->
        <rest path="/students" consumes="application/json" produces="application/json">
            <description>Student service</description>

            <!-- this is a rest GET to view an user by the given id -->

            <get outType="temp.org.model.Student[]">
                <description>Get All Students</description>
                <responseMessage code="200" message="Student details" />
                <to uri="bean:StudentService?method=getStudents()" />
            </get>
            <post type="temp.org.model.Student"
                outType="temp.org.model.Student[]">
                <description>Query Student Object</description>
                <param name="body" type="body" description="Querying Student Object"
                    required="true" />
                <responseMessage code="404" message="Student not found" />
                <responseMessage code="200" message="Student details" />
                <route id="getStudentRoute">
                    <to uri="bean:StudentService?method=getStudent(${body})" />
                    <filter>
                        <simple>${body} == null</simple>
                        <setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
                            <constant>404</constant>
                        </setHeader>
                    </filter>
                    <filter>
                        <simple>${body} != null</simple>
                        <setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
                            <constant>200</constant>
                        </setHeader>
                    </filter>
                </route>
            </post>
            <delete type="temp.org.model.Student">
                <description>Delete alarm</description>
                <param name="body" type="body" description="Delete Student Object"
                    required="true" />
                <responseMessage code="404" message="Student not found" />
                <responseMessage code="200" message="Student deleted Successfully" />
                <to uri="bean:StudentService?method=deleteStudent(${body})" />
            </delete>
            <post type="temp.org.model.Student">
                <description>Insert alarm</description>
                <param name="body" type="body" description="Insert Student Object"
                    required="true" />
                <to uri="bean:StudentService?method=insertStudent(${body})" />
            </post>
        </rest>
    </camelContext>
</beans>
camel swagger是否支持rest服务中的多个post方法?如果是的话,谁能给我提供一个样品来克服我所得到的错误


期待您的解决方案。提前感谢。

您如何区分两个
POST/student
操作中的哪一个应该调用?是的。我也有同样的想法。因此,关于这一点,我还有一个问题,我们是否可以创建独特的post方法,使用body作为请求参数不同的post必须位于不同的路径上…感谢beny的回复。但是你能举个例子吗。
2016-03-08 15:57:00,736 [ost-startStop-1] ERROR ContextLoader                  - Context initialization failed
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToStartRouteException: Failed to start route route1 becau
se of Multiple consumers for the same endpoint is not allowed: Endpoint[servlet:/students?httpMethodRestrict=POST]
        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1642)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMult
icaster.java:151)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMult
icaster.java:128)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:3
31)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:
775)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434
)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of Multiple consumers for
the same endpoint is not allowed: Endpoint[servlet:/students?httpMethodRestrict=POST]
        at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3486)
        at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3462)
        at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3392)
        at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3160)
        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3016)
        at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812)
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808)
        at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831)
        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808)
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777)
        at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
        ... 22 more