該應用程序使用JDK 8,Spring Boot和Spring Boot Jersey啟動程序,并打包為WAR(盡管它是通過Spring Boot Maven插件在本地運行的)。我想做的是獲得我在運行中(在構建時)生成的文檔作為歡迎頁面。我嘗試了幾種方法:通過按照此處所述配置application.properties 適當的init參數,讓Jersey提供靜態內容引入metadata-complete=false web.xml以便將生成的HTML文檔列出為歡迎文件。這些都沒有解決。我想避免不得不啟用Spring MVC或創建僅用于提供靜態文件的Jersey資源。任何想法?這是Jersey的配置類(我嘗試在那添加一個失敗ServletProperties.FILTER_STATIC_CONTENT_REGEX):@ApplicationPath("/")@ExposedApplication@Componentpublic class ResourceConfiguration extends ResourceConfig { public ResourceConfiguration() { packages("xxx.api"); packages("xxx.config"); property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); }}這是Spring Boot應用程序類(我嘗試添加application.propertieswith,spring.jersey.init.jersey.config.servlet.filter.staticContentRegex=/.*html但沒有用,我不確定在這里應該使用什么屬性鍵):@SpringBootApplication@ComponentScan@Import(DataConfiguration.class)public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); }}
3 回答

慕森卡
TA貢獻1806條經驗 獲得超8個贊
以下設置對我有用
組
spring .jersey.type: filter
設置 FILTER_FORWARD_ON_404
@Configuration
public class MyResourceConfig extends ResourceConfig {
public MyResourceConfig () {
try {
register(XXX.class);
property(ServletProperties.FILTER_FORWARD_ON_404, true);
} catch (Exception e) {
LOGGER.error("Exception: ", e);
}
}
}
注意:使用@Configuration 而不是@component
添加回答
舉報
0/150
提交
取消