gpt4 book ai didi

java - 需要 springmvc-router 配置帮助

转载 作者:太空宇宙 更新时间:2023-11-04 13:48:17 25 4
gpt4 key购买 nike

我遵循了本教程 http://resthub.github.io/springmvc-router/使用routes.conf文件实现Spring路由。使用下面的代码

// Configuration code as mentioned in tutorial
import java.util.ArrayList;
import java.util.List;

import org.resthub.web.springmvc.router.RouterConfigurationSupport;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = "my base pack")
// You should not use the @EnableWebMvc annotation
public class WebAppConfig extends RouterConfigurationSupport {

@Override
public List<String> listRouteFiles() {

List<String> routeFiles = new ArrayList<String>();

routeFiles.add("routes.conf");

return routeFiles;
}
}

routes.conf 位于 src\main\resources

springmvc-router没有选择routes.conf文件

我遇到以下异常:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'handlerMapping' defined in ServletContext
resource [/WEB-INF/axpense-servlet.xml]: Initialization of bean failed;

nested exception is org.resthub.web.springmvc.router.exceptions.RouteFileParsingException:
Could not read route configuration files;

nested exception is java.io.FileNotFoundException:
Could not open ServletContext resource [/routes.conf] at
org.springframework.beans.factory.support.AbstractAutowireCapableBean

最佳答案

只需替换该行routeFiles.add("routes.conf");使用routeFile.add(classpath:/routes.conf);//为我工作

关于java - 需要 springmvc-router 配置帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30589516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com