使用spring-data-rest和spring-创建一个快速入门的web应用模板。
我希望根/被允许进入src/resources/public/index.html文件,这样我就可以启动前端,但是使用/,org.springframework.data.rest.webmvc.RepositoryController被映射到/。
我如何将它的映射移动到/rest呢?我可以找到如何修改BaseUrl的RestRepositories,而不是如何释放/?
发布于 2014-11-15 02:03:32
配置基本浴缸很简单。扩展RepositoryRestMvcConfiguration (无论是在主应用程序类中还是在单独的配置类中),然后按如下方式覆盖其主配置例程:
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
super.configureRepositoryRestConfiguration(config);
try {
config.setBaseUri(new URI("/rest"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}发布于 2014-11-11 18:57:04
为什么要在与前端应用程序相同的路径上直接运行API?
这应该在两个单独的应用程序中完成。Spring数据+ Rest应该用于创建API,而不是使用您的前端(它可能运行在其他简单的apache上)来调用作为后端开发人员创建的RESTful API。
在这里您可以找到我对RESTFul API的答案:Where to put forms / alternative views in a RESTful html app?
如您所见,API正在服务器的另一个服务器/部分上运行。
https://stackoverflow.com/questions/26872286
复制相似问题