我有两个项目 1.项目UI(包含角度页面) 2. Project-REST(休息Web服务)
最初他们曾经在同一个tomcat上,因此我可以使用url“/ Project-REST / Customer / id / 1234”调用任何REST资源,因为上下文路径相同,例如本地主机:8080
现在,Project-REST已经转换为Spring启动,并使用内置的tomcat启动端口,例如8085.所以我的相对网址不起作用。
有没有办法使它工作,所以我不需要改变我的所有网址.....没有进入上下文路径?
我使用eclipse作为IDE
答案 0 :(得分:0)
Here are 3 suggestions in random order:
All requests go to tomcat (Project-UI, port 8080), where you configure URL rewriting to redirect some requests to spring-boot (Project-REST port 8085). A quick google search produced this and this, both similar to mod_rewrite
of Apache.
If as I understand &Project-UI* one contains static files, you can easily serve these from your spring-boot application at port 8085. Spring boot docs for serving static content here. In summary spring-boot will serve static content from a directory called /static
(or /public
or /resources
or /META-INF/resources
) in the classpath or from the root of the ServletContext
.
Put a proxy server in front of both Project-UI and Project-REST and configure request redirects there. This is a more involved solution but may help you if you more projects in the future.