小编Ric*_*kin的帖子

如何解决 Apache Camel 中的“无法创建路由 route1 异常”?

我是 Apache Camel 概念的新手。我曾尝试使用 apache camel API 编写示例代码,但在尝试运行代码时出现以下异常。

谁能帮我解决这个问题?

这是示例代码和一个例外,

示例代码:

 CamelContext context = new DefaultCamelContext();
 context.addRoutes(new RouteBuilder() { 
  public void configure() {
    from("direct:start")
    .setHeader(Exchange.HTTP_URI,simple("`http://sample-host:8080/demo/get`"))
    .to("http://emptyhost");
  }
 });
 context.start();
 ProducerTemplate template = context.createProducerTemplate();
 System.out.println(template.requestBodyAndHeaders("direct:start", null, null,String.class));
Run Code Online (Sandbox Code Playgroud)

例外 :

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: 
Failed to create route route1 at: 
    >>> To[`http://sample-host:8080/demo/get`] <<< 
in route: Route(route1)
    [[From[direct:start]] -> [`To[http://sample-host:8`…
because of 
    Failed to resolve endpoint: `http://sample-host:8080/demo/get`
due to: 
    No component found with scheme: http
Run Code Online (Sandbox Code Playgroud)

java apache-camel

7
推荐指数
1
解决办法
2万
查看次数

如何从HashMap中删除重复值

我不知道如何最好地描述我的问题,但在这里,我正在尝试从中删除相同的名称(值) HashMap<String, String> map = new HashMap<String, String>();

例如,如果这张地图包含这样的名字

    map.put("Vivaldi","Antonio");
    map.put("Belucci", "Monica");
    map.put("Gudini", "Harry");
    map.put("Verdo", "Dhuzeppe");
    map.put("Maracci", "Bruno");
    map.put("Carleone", "Vito");
    map.put("Bracco", "Luka");
    map.put("Stradivari", "Antonio");
Run Code Online (Sandbox Code Playgroud)

我想使用 method 从中删除所有值为“Antonio”的条目removeTheFirstNameDuplicates,我在谷歌上看了几天,所有的例子都接近我想要的,但并不是我真正需要的。

我的想法是,我需要一些东西来检查地图,如果其中包含相同的值,则删除重复项。但是我该怎么做呢?

java hashmap

3
推荐指数
1
解决办法
1万
查看次数

如何通过提供仅POST @Valid来删除多余的Spring MVC方法?

我有一个表单处理Spring MVC控制器,带有JSR-303 bean验证@Valid.

整个处理GET程序的唯一目的是(几乎)相同POST,但省略@Valid注释以防止在提交表单之前<form:errors ...>在第一个用户GET请求中显示JSP中的错误.

我的问题是:

  • 如何GET以干净的方式删除冗余方法?
  • 我怎么能POST只做一个@Valid

这是我的示例代码:

@RequestMapping( value = "/account/register" , method = RequestMethod.GET )
public String registerGet( @ModelAttribute( "registerForm" ) RegisterForm registerForm ) {
    return "account/register";
}

@RequestMapping( value = "/account/register" , method = RequestMethod.POST )
public String registerPost( @ModelAttribute( "registerForm" ) @Valid RegisterForm registerForm ,
        BindingResult result ,
        RedirectAttributes redirectAttributes ) {

    ... ADD USER HERE IF …
Run Code Online (Sandbox Code Playgroud)

java spring jsp spring-mvc bean-validation

2
推荐指数
1
解决办法
1269
查看次数

如何访问链接列表的元素?

由于Java中没有自引用指针概念......如何解决此问题...

我不允许在Java中使用内置类链接列表...

但是"应该像在C中一样遵循链接列表的创建方法".什么可能是最好的替代节点 - >接下来,节点 - > Java中的prev ...

java linked-list

1
推荐指数
1
解决办法
144
查看次数

如何计算无状态服务中的递归次数?

是否可以计算不应维护任何有状态变量的服务中的迭代次数?

@Service //stateless spring service singleton
class MyService {
    //this is clearly not stateless
    int iterations = 0;

    ResultVO run() {
        interations++;
        do();
        some();
        subroutines();
        if (validationFails() && iterations <= 3) { 
            run(); //retry the iteration steps only 3 times
        } else {
            throw TooManyIterationsException();
        }
        return resultVO;
    }
}
Run Code Online (Sandbox Code Playgroud)

java spring loops

1
推荐指数
1
解决办法
77
查看次数

Delete the content of csv file in Java

Every day I update a csv file using a FileWriter. When we step into a new month I have to delete the data from the previous month. My below code only updates a data in a csv file so, please help in deleting the previous month's data.

At least I need to know how to delete the data in csv file using FileWriter, so that I can manage to code for deleting previous month data.

        private static void …
Run Code Online (Sandbox Code Playgroud)

java csv

1
推荐指数
1
解决办法
5626
查看次数