在弹簧靴和球衣后端运行编译的 Angular 屏幕



我花了相当多的时间努力让弹簧启动来提供我的角度屏幕,同时也为我们的后端服务。 我承认我对弹簧/球衣领域很陌生,所以我可能没有问正确的问题或搜索他正确的东西。

类似于这篇文章 Spring Boot - 如何提供 Angular2 编译文件 我有一些编译的角度屏幕,以及一些我想在单个 jar 文件中运行的休息端点。 我已经尝试了那篇SO文章中发布的示例,但没有运气。

只要我不包含我的 JerseyConfig 类,我就可以让单个索引.html文件工作

@Component
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(WorkflowManagementResourceV1_0.class);
}
}

但是当我删除泽西配置时,我的端点不再启用。

我也从未设法让编译的 Angular 屏幕在春天出现。

我尝试过将东西放在资源/静态、资源/公共/网络应用程序/资源等中。

我会很高兴地添加更多内容和细节,但首先我很好奇这是否仍然可能(我认为是)。 其次,是否需要进行某种配置、pom 依赖项或自动配置才能启用此功能?

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

@SpringBootApplication
@Controller
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

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

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

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

添加 Spring Web 依赖项(如果还没有

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

在 application.properties 中,配置泽西岛筛选器:

spring.jersey.type=filter

最后,将泽西配置为在泽西配置中转发 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);
}
}

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

最新更新