在弹簧靴和平针织后端内运行编译的角度屏幕

问题描述 投票:0回答:1

我花了很多时间努力让弹簧靴提供我的角度屏幕,同时也为我们的后端服务。我承认我对春季/运动衫领域很陌生,所以我可能不会问正确的问题或者正确的搜索。

类似于这篇文章Spring Boot - How To Serve Angular2 Compiled Files我有一些编译的角度屏幕,以及我想在一个jar文件中运行的一些休息端点。我试过那篇SO文章中发布的例子,但没有运气。

只要我不包含JerseyConfig类,我就可以获得一个index.html文件

@Component
public class JerseyConfig extends ResourceConfig {

   public JerseyConfig() {
      register(WorkflowManagementResourceV1_0.class);
   }
}

但是当我删除JerseyConfig时,我的端点不再被启用。

我也从未设法让编译好的Angular屏幕出现在Spring内部。

我试过把东西放在资源/静态,资源/公共/ webapps /资​​源等。

我会很乐意添加更多的内容和细节,但首先我很好奇这是否还有可能(我认为是这样)。第二是是否需要进行某种配置,pom依赖或自动配置才能启用此功能?

我也尝试将@Controller添加到我的主应用程序中

@SpringBootApplication
@Controller
public class Application {

   public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
   }
}
angular spring-boot
1个回答
1
投票

我有类似的问题,发现以下文章非常有用:

https://www.geekmj.org/jersey/spring-boot-jersey-static-web-files-support-403/

基本上,泽西岛正在接管所有要求。本文中描述的方法是将Jersey配置为转发404。由于对静态内容的请求是对泽西岛的404,它将转发它,它将由底层系统自动处理。

如果您还没有它,请添加Spring Web依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

在application.properties中,配置Jersey过滤器:

spring.jersey.type=filter

最后,配置Jersey以在JerseyConfig中转发404:

@Component
public class JerseyConfig extends ResourceConfig {

   public JerseyConfig() {
       register(WorkflowManagementResourceV1_0.class);

       // set jersey to pass 404's to the underlying system (this makes the screens work)
       property(ServletProperties.FILTER_FORWARD_ON_404, true);
   }
}

毕竟,您的静态内容应该可用!

© www.soinside.com 2019 - 2024. All rights reserved.